Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hyperlinks terminal escapes #922

Closed
passcod opened this issue Nov 28, 2017 · 32 comments · Fixed by #6139
Closed

Support hyperlinks terminal escapes #922

passcod opened this issue Nov 28, 2017 · 32 comments · Fixed by #6139

Comments

@passcod
Copy link

passcod commented Nov 28, 2017

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

This is supported in iTerm2 and Gnome Terminal.

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

displays This is a link with some formatting (in gnome term it's a dotted underline) and is clickable to open the given hyperlink.

Tmux currently has no support, so until that happens it's likely not going to be too useful in alacritty, but still a cool feature nonetheless.

@jwilm
Copy link
Contributor

jwilm commented Nov 29, 2017

@passcod thanks for filing the issue! This is the approach I had in mind for URL handling. I thought there was another issue for it, but all I can find is #113, and that's not quite the same.

@chrisduerr
Copy link
Member

chrisduerr commented Jan 5, 2018

Are there any applications that actually use this though? I feel like implementing a feature to display URLs when no application will ever use it, seems like a waste.

IRC clients like weechat do not support this as far as I know. And it looks like most terminal emulators also do not support this.

@jwilm
Copy link
Contributor

jwilm commented Jan 6, 2018

@chrisduerr The more I think about this, it really seems like we need to support both. URL detection is good for a lot of common use cases, but full screen apps like weechat will benefit from the escape sequence.

Even if weechat doesn't already support it, adding a plugin which modifies output really wouldn't be too much work (run parser to find html, wrap with escape sequence).

@chrisduerr chrisduerr self-assigned this Jan 25, 2018
@wayneashleyberry
Copy link

wayneashleyberry commented Mar 26, 2018

Although not published yet, there's an interesting npm package for rendering these links here: https://github.com/sindresorhus/ink-link. It would be amazing if these could render correctly in Alacritty!

@leezu
Copy link

leezu commented Jun 25, 2018

systemd now makes use of this

@chrisduerr
Copy link
Member

Huh, I didn't expect any major adoption at this point. That's really good to hear, thanks for the heads-up!

I think it would still make sense to implement both in one go, but that shouldn't be too much additional work.

@chrisduerr chrisduerr removed their assignment Jul 19, 2018
@aperum
Copy link

aperum commented Jul 27, 2018

Isn't this a huge security risk without a preview? One could easily do:

echo -e '\e]8;;http://bad.link\ahttp://good.link\e]8;;\a'

Or not?

@chrisduerr
Copy link
Member

Alacritty can show the real URL on hover the same way a Browser does.

The functionality to render text at the bottom of the terminal already exists for drawing the redraw timer and has also been used in #1188.

@tblancher
Copy link

Has this been implemented? I see a problem with long, wrapped URLs in mutt, in both and outside of tmux. The URL grabber only appears to get the first apparent line of the URL.

I'm just trying alacritty for the first time, and this will keep me from using it as my daily driver. In urxvt, I have to load a custom Perl mapper script to get wrapped URLs to be fully clickable, so alacritty isn't alone with this problem.

@kchibisov
Copy link
Member

@tblancher mutt doesn't wrap urls the way you expect iirc (it wrap it with it's pager, but doesn't set WRAP on a cell), you can pipe a message to a less though (That's what I'm doing here).

@tblancher
Copy link

tblancher commented Oct 12, 2019 via email

@kchibisov
Copy link
Member

I've noticed that less allows most URLs to be clickable, but not all of them
(in the same message). Also, you lose a lot of the controls within mutt by not
using the builtin pager.

I'm not suggesting to use other pager, I'm suggesting to pipe message content to less on demand when you want to open urls which were wrapped by mutt's pager. So, this binding should give you better understand on what I'm talking about (just press Shift + U while reading a message with mutt's pager).

macro pager U "\
:set my_tmp_pipe_decode=\$pipe_decode\n\
:set pipe_decode\n\
|less\n\
:set pipe_decode=\$my_tmp_pipe_decode\n\
:unset my_tmp_pipe_decode\n"

Anyway this issue is a bit different from your problem. I don't think that mutt supports this escapes.

@tblancher
Copy link

tblancher commented Oct 14, 2019 via email

@lachesis
Copy link

This is now used by GCC-10's static analysis warnings with the -fanalyzer option. See this redhat blog entry and ctrl-f suitable terminal for more details. I would love to have this feature in Alacritty as well.

@pothos
Copy link

pothos commented May 10, 2020

It's also used by ls which is great to open any file or folder with the standard application (like xdg-open file://…some.pdf):

$ ls --hyperlink=auto

@legrostdg
Copy link

alacritty also fails to recognize multiline urls in vim

@kchibisov
Copy link
Member

It fails because vim splits those with \n. The url managing in such(alt screen) apps is up to app. If you try multi line url by printing it via echo it'll work. Nothing we can do about such urls in vim, because the url is on 2 logical lines, not a 1 logical line, like it'll be with echo.

@sersorrel
Copy link

Nothing we can do about such urls in vim

well, implementing support for the hyperlink escape sequence would be one piece of the puzzle :) the other piece being a vim plugin or patch to vim itself to make it emit that escape sequence in the appropriate places.

@kchibisov
Copy link
Member

well, implementing support for the hyperlink escape sequence would be one piece of the puzzle :) the other piece being a vim plugin or patch to vim itself to make it emit that escape sequence in the appropriate places.

I mean if vim supported that escape sequence then we can do something about it, but vim doesn't support it, meaning that in a current point in time we can't do anything about that. If vim will support that escape sequence than we can do something about it by implementing the escape sequence.

@chrysn
Copy link

chrysn commented Jan 12, 2021

Please let's not get hung up too much on particular applications that don't have support for this yet (especially those like mutt that generally can only guess as well) -- sure, vim or mutt support would make this even more useful, but given how systemd, ls and gcc already produce useful enough links, this should not be a chicken and egg problem any more.

@adrian-gierakowski
Copy link

adrian-gierakowski commented Feb 6, 2021

this feature is a must for any modern terminal IMHO

here's another useful application: a couple of wrappers for ripgrep/vim which allow one to open files in vim at the exact location of a match found by ripgrep: https://github.com/lilydjwg/search-and-view

@aeneby
Copy link

aeneby commented Jun 14, 2021

I agree with @aperum above - this is a security risk. Browsers, mail clients, etc have the ability to show a preview link before you click. I hope this doesn't become a thing.

@chrysn
Copy link

chrysn commented Jun 15, 2021

I wouldn't put too much thought to the "one URI shown, a different one clicked" aspect. In the end it's up to registered URI handlers to behave reasonably safe. "Looks like an URI" is quite hard to tell (that's a reason for this in the first place), and there can be good reasons for differences. (Eg. "Why you shouldn't use example.com" won't go to example.com even though today's overzealous autolinkers would make it go there).

A preview is nice and customary, but mobile environments only show link targets when asked too.

@aeneby
Copy link

aeneby commented Jun 15, 2021

In the end it's up to registered URI handlers to behave reasonably safe

I realise there will be differing opinions on this, but I have to disagree. Users need to be able to make informed choices about what they're clicking on.

@chrysn
Copy link

chrysn commented Jun 15, 2021 via email

@oxalica
Copy link
Contributor

oxalica commented Jun 15, 2021

What to do on click

Maybe worth mentioning that, KDE konsole open the link on Ctrl+Click instead of direct click. I think this should be preferred. We should not override the left-button-click behavior for the program inside the tty.

@ewtoombs
Copy link

A URL tooltip when mousing over is necessary, but if it has that, this would be an insanely useful feature to have.

kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 15, 2022
This commit adds support for hyperlink escape sequence OSC 8.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 16, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jun 29, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jul 6, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jul 10, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`.

Fixes alacritty#922.
kchibisov added a commit to kchibisov/alacritty that referenced this issue Jul 10, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`. The configuration option responsible for
those is `hints.enabled.hyperlinks`.

Fixes alacritty#922.
kchibisov added a commit that referenced this issue Jul 10, 2022
This commit adds support for hyperlink escape sequence
`OSC 8 ; params ; URI ST`. The configuration option responsible for
those is `hints.enabled.hyperlinks`.

Fixes #922.
@XhstormR
Copy link

XhstormR commented Dec 1, 2023

I have a question, this hyperlinks feature won't work with tmux latest version 3.3, right?

@kchibisov
Copy link
Member

ask tmux, it's up to it to handle it, since it's also a terminal emulator. If tmux has setting to enable it'll work.

@lilydjwg
Copy link

lilydjwg commented Dec 1, 2023

Only latest tmux git works fine, and you need set set -ga terminal-features "*:hyperlinks".

@fma0x
Copy link

fma0x commented Dec 4, 2023

When putting Alacritty in vi mode, I just press shift and click. It works for me.

And I tested again, and only shift solves it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment