4

I am creating Log-Reports which are viewable through the Web-browser. Is there an easy way to make links clickable in Linux Terminal? (Gnome-Terminal)

I am copying those links and manually open my web-browser to achieve that right now.

7

If the links are output as full URLs, they should be clickable when you hover over them (with the mouse pointer) while holding Ctrl down.

  • Awesome! Is it possible to do hyperlinks as well? – user1767754 May 20 '16 at 15:01
  • @user1767754 if you mean text which doesn't look like a URL, but is clickable and associated with a URL, then no, it only recognises URLs and email addresses, you can't dress things up as hyperlinks. – Stephen Kitt May 20 '16 at 15:40
  • 1
    @StephenKitt Is there a way to get the terminal recognise filenames? I mean clickable link to a file which opens up in default editor? – stillanoob Jul 8 '17 at 23:47
  • @ibrahim5253 see my comment just above yours: GNOME Terminal only recognises URLs and email addresses. It would be very hard (if not impossible) to process file names reliably. (For example, if you run ls /some/other/dir, how can the terminal know where to find the files whose names are listed?) – Stephen Kitt Jul 9 '17 at 7:36
  • @StephenKitt I get your point. How about if it is only required to recognise absolute paths? Anything that does match /(.*/)*[^/]+ need not be considered. – stillanoob Jul 9 '17 at 14:53
6

Newer version of GNOME terminal now support hyperlinks with custom target via certain escape sequences. Try

echo -e '\e]8;;http://example.com\aThis is a link\e]8;;\a'

Opening these works the same way as described in the answer by Stephen Kitt.

See also: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.