1

Is there a way to make the Terminal support the OSC 8 styled hyperlinks?

This,

printf '\033]8;;http://example.com\033\\This is a link\033]8;;\033\\\n'

Just prints out This is a link. But it is not clickable.

6
  • 1
    Terminal isn’t an HTML renderer. However, iTerm2 does have limited capabilities of rendering links.
    – Allan
    May 23 at 0:40
  • The question isn't about rendering HTML.
    – scribe
    May 23 at 0:58
  • I agree with @Allan here, from where you took the command line, it states "The result is equivalent to this HTML link". Have you even read the title of the article? "Hyperlinks (a.k.a. HTML-like anchors) in terminal emulators"
    – Thinkr
    May 23 at 7:02
  • ANSI escape codes are majorly used in the terminal to colour text. The link the body gives a list of terminal emulators that render this Operating System Command 8 as a proper hyper link. "Have you even read the title of the article?" yes, I am sorry, but did you read past the title of the one I linked? Quoting the first line, "This document tracks in-the-wild support for terminal hyperlinks (a.k.a., OSC 8), primarily amongst terminal emulators."
    – scribe
    May 23 at 7:10
  • Ok, so what’s the question here. The link you supplied lists several terminal emulators including iTerm2 that do what you’re looking for; Apple’s Terminal isn’t one of them. Do you believe there’s a hidden setting that enables this feature?
    – Allan
    May 23 at 13:59

1 Answer 1

1

This has come up before (see Is there a way to make a link clickable in the OSX Terminal?, Configure OS X Terminal to detect URLs and make them clickable?), and it seems not to be possible to use OSC 8 in macOS Terminal.

It also isn't required. You can just double-click with Cmd pressed on any URL shown in a Terminal window to have it open in the default browser.

You can use Terminal capabilities to underline text with tput

tput smul; echo https://apple.stackexchance.com/; tput rmul

but this might be confusing because the click behavior is not the same as in a browser.

2
  • Yeah, that feature should be added
    – Thinkr
    May 23 at 16:18
  • The OSC 8 style does not just make hyperlinks clickable, it also allows you to show a label instead of apple.stackexchange.com/q/460189/494729. See? The questions you linked are almost a decade old so I hoped that maybe there was an update or some new way.
    – scribe
    May 23 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .