You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I'm going to close this. I don't see a lot of other tools doing this, and it should be possible to write a wrapper script to do this for you if you really want it.
I think this should be reopened and properly considered. Its insanely useful. Certain terminal apps such as iterm2 does it by default. But it could work across ALL of them if rg outputted links with the file:// syntax.
Reacted by Sander Maijers, Deon Groenewald, Forrest Smith, Jakob Gerhard Martinussen, neeasade, bluss and Christina Sørensen
@BurntSushi I am not quite sure how this is implemented, but I just learned that ls has a feature ls --hyperlink=auto (or always or never), which causes it to emit things with ANSI shell magic that makes them clickable links in my terminal. Here's an example:
If ls can have nice things, surely a program as awesome as rg can 😂
Reacted by Ray Lee, bluss, Michael F. Schönitzer, Joshua Trees, Guilhem Saurel, mentalisttraceur, Sun Wuan, alex , Jasper Poppe, Paul Wagland and 3 more
Any chance this will be reopened? As mentioned above, there is widespread support for hyperlinks on modern terminal emulators and tools like ls have built-in support for this.
Reacted by Alex Sheluchin, Jakob Gerhard Martinussen, Artturin, Adrian, Joseph Wright, Yang Tang, Ronan Jouchet, Joshua Trees, Brian Di Palma, Mateusz Wieloch and 4 more
The following things seem to be needed for supporting hyperlinked file paths in ripgrep. I'm just writing for no reason, maybe it's useful.
Resolve paths to absolute paths (I would suggest do so without touching the filesystem, don't want canonicalization) and url escape paths to be printable-ascii-safe as file:// URIs.
Lookup current hostname (bonus feature but should preferably be in the URL according to the spec, this seems to be a bit of a layer-busting complication)
Add cli parameter --hyperlink={always|ansi|auto|never} (I don't know if ansi is useful here, but I think so)
Use the hyperlink escapes in the printer crate. I'm not sure if it's a great fit to try to put it inside termcolor - even if the spec says it works very similarly to colors.
This feature is supported with the same escape code in Linux (various terminals including gnome-terminal), Windows (microsoft/terminal), macos (iTerm2). The pager less supports it in new versions.
@bluss Thanks for laying that out! Some quick feedback:
If possible, I'd like to avoid the hostname lookup aspect of this. You're spot on about it being layer busting. I think the key thing here is, what does the hostname buy us? i.e., What do we lose if we don't bother with it.
Putting this inside of termcolor might be nice to be honest, especially if it's an ANSI escape sequence. Or at least, putting the emission of that ANSI escape inside termcolor would be good. Having it be outside of termcolor would probably be more problematic.
When supporting the legacy Windows console, I think we would just not emit the escape sequence, like we do now for things not supported by the Windows console.
I think that's all I can think of for right now. I'll re-open.
Reacted by bluss, Brian Di Palma, mentalisttraceur and Paul Wagland
For anyone following this issue, there is active discussion about adding support for it in this PR: #2483
Opinions are welcome because this is clearly a very thorny feature to add support for. It is not simple and it looks like it is going to be integration specific. I won't be surprised if I get this wrong in some way in the initial release unfortunately.
Reacted by Jon Smithers, Jasper Poppe and andriantoeff
Activity
BurntSushi commentedon Nov 6, 2017
Do other command line tools have an option like this? I don't think I've seen anything like it.
sanmai-NL commentedon Nov 7, 2017
@BurntSushi: I don't know off the top of my head. You also encounter such such links while paging log output, for example.
To be clear, this isn't a question but a feature request. 🙂
Similar feature requests
file://prefix on console to make them clickable (on supporting shells) robotframework/robotframework#2435Added value
wgetandcurlkpp commentedon Nov 23, 2017
You may do the same for
rgwithout modifying it.BurntSushi commentedon Jan 31, 2018
I think I'm going to close this. I don't see a lot of other tools doing this, and it should be possible to write a wrapper script to do this for you if you really want it.
sanmai-NL commentedon Sep 15, 2018
@BurntSushi:
Important interesting precedent: https://github.com/systemd/systemd/blob/903511951892008b991991962fef2e8ecc65bc6c/NEWS#L220-L232.
adrianocr commentedon Jul 22, 2019
I think this should be reopened and properly considered. Its insanely useful. Certain terminal apps such as iterm2 does it by default. But it could work across ALL of them if rg outputted links with the
file://syntax.alex commentedon Jun 28, 2020
@BurntSushi I am not quite sure how this is implemented, but I just learned that
lshas a featurels --hyperlink=auto(oralwaysornever), which causes it to emit things with ANSI shell magic that makes them clickable links in my terminal. Here's an example:If
lscan have nice things, surely a program as awesome asrgcan 😂saleemrashid commentedon Jun 28, 2020
This is fairly comprehensive documentation on the hyperlink feature that @alex mentioned: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
mx-psi commentedon Aug 5, 2020
Any chance this will be reopened? As mentioned above, there is widespread support for hyperlinks on modern terminal emulators and tools like
lshave built-in support for this.kovidgoyal commentedon Oct 6, 2020
FYI: Here is a wrapper implementation that actually allows you to click on results and open them in your editor at the matched line. https://sw.kovidgoyal.net/kitty/kittens/hyperlinked_grep.html
Note that it works with the kitty terminal.
adrian-gierakowski commentedon Feb 6, 2021
@BurntSushi would you be so kind and reconsider? it would be amazing to have it supported out of the box and not have to use wrappers
bluss commentedon May 13, 2021
The following things seem to be needed for supporting hyperlinked file paths in ripgrep. I'm just writing for no reason, maybe it's useful.
file://URIs.This feature is supported with the same escape code in Linux (various terminals including gnome-terminal), Windows (microsoft/terminal), macos (iTerm2). The pager less supports it in new versions.
BurntSushi commentedon May 13, 2021
@bluss Thanks for laying that out! Some quick feedback:
I think that's all I can think of for right now. I'll re-open.
32 remaining items
097115 commentedon Apr 10, 2023
@ltrzesniewski
Thanks for your builds!
However, the hyperlinks seem not to work under
tmux(lsstill works, though). Tested inkittyandalacritty.nbenitez commentedon Apr 10, 2023
@097115 Excerpt from https://superuser.com/questions/1771573/file-hyperlink-not-working-under-tmux :
Support for hyperlinks has been added to tmux in Git a few months ago and will be available in the next release, probably 3.4
097115 commentedon Apr 10, 2023
I'm on 3.4 and as I said in my first comment,
ls --hyperlink=alwaysdoes work for me intmux. While @ltrzesniewski's custom build ofrgdoesn't.ltrzesniewski commentedon Apr 10, 2023
@097115 thanks for your feedback. I'll take a look.
ltrzesniewski commentedon Apr 12, 2023
@097115 I believe this is an issue in tmux, and have reported it here: tmux/tmux#3525
097115 commentedon Apr 13, 2023
Thanks again, Lucas!
BurntSushi commentedon Sep 22, 2023
For anyone following this issue, there is active discussion about adding support for it in this PR: #2483
Opinions are welcome because this is clearly a very thorny feature to add support for. It is not simple and it looks like it is going to be integration specific. I won't be surprised if I get this wrong in some way in the initial release unfortunately.
hyperlink: rejigger how hyperlinks work
hyperlink: rejigger how hyperlinks work
BurntSushi commentedon Sep 25, 2023
Support for hyperlinks is on master. I would love feedback here: #2611
textproc/ripgrep: update to 14.0.2
textproc/ripgrep: update to 14.0.2
textproc/ripgrep: update to 14.0.2
textproc/ripgrep: update to 14.0.2