Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make a link clickable in the OSX Terminal?

People also ask

How do I click a link in Mac terminal?

cmd + shift + double-click on a URL in Terminal.

How do you make a link clickable on a Mac?

Select the text or object that you want to make into a hyperlink. On the Home tab, under Insert, click Text, and then click Hyperlink. In the Link to box, enter the Web address.

How do I make a URL clickable?

Create a hyperlink to a location on the webSelect the text or picture that you want to display as a hyperlink. Press Ctrl+K. You can also right-click the text or picture and click Link on the shortcut menu. In the Insert Hyperlink box, type or paste your link in the Address box.


Before OSX Lion:

cmd+shift+double-click on a URL in Terminal.app and it will open in the default program.

OSX Lion:

cmd+double-click (otherwise you will enter fullscreen mode).


You can right click on a URL in Terminal and the first option in the context-sensitive menu is "Open URL". Not perfect, but maybe good enough ?


Others have discussed how you can select and Command-click on text which is a valid URI. As for Command-clicking on an embedded hyperlink, just like an anchor in hypertext (i.e., where the displayed text is not the URI itself), I believe the short answer is: Terminal cannot do it, but iTerm2 can.

Bash (or any other program that prints to a tty) can output the appropriate escape sequence to create a clickable hyperlink: it is \x1B]8;;URI\x1B\\TEXT\x1B]8;;\x1B\\, where \x1B represents the escape character, \\ represents a literal backslash, URI is the URI you want to link to (starting with https://, file:///, or whatever), and TEXT is the text you want to actually appear, for the user to Command-click on. (You can also use \a, the alert or bell character, instead of both instances of \x1B\\, but I understand this is less standard.) For example:

See \x1B]8;;file:///path/to/help/file\x1B\\the help file\x1B]8;;\x1B\\ for details.

In Mac OS(X), under El Capitan in my case, this works perfectly with iTerm2, and shows:

See the help file for details.

except that the linked text the help file has a dotted underline instead of being in italics. Command-clicking anywhere on the linked text opens the specified URI in the default browser. (Incidentally, this is also the behaviour in the Terminal program in Ubuntu Linux.)

In Mac OS(X) Terminal, you just get:

See the help file for details.

with no special typography and no ability to Command-click on any part of it.

You can get the full detail, including a list of supporting terminals, at https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda.