Hacker News new | ask | show | jobs
by lelandbatey 932 days ago
The notes state that the headline feature is "hyperlink support". However, the notes don't seem to really explain what that means. Can someone explain a bit more about what that feature does/is? What's a use case?
4 comments

So, when you search for "foo" in mydir/, rg can find the term foo inside different places in a number of files, and then print the results like:

  mydir/myfile.java
  15: return foo;
  78: System.out.println(foo);
  123: // TODO: change foo to bar
Hyperlink support means that the line numbers (15, 78, 123) are clickable, and will open your favorite editor to that file and that line number.

That's if your terminal supports hyperlinks, or has hyperlink support enabled - most do. Depending on the terminal app it might be control/cmd click, or option-click to open the hyperlink.

Note (this got me while trying): hyperlinks are not emitted when you search inside a specific file directly, e.g. "rg foo myfile.py".

I'm fascinated! I've been living with and authoring CLI tools for about a decade now and I didn't know that there's widespread support for additional attributes on text besides styling (color, italics, underline, etc) in common terminal emulators. What a cool thing!
For the single file case, if you pass --with-filename then it should work.
Sibling comments have explained, but the keyword to search to learn more is "OSC-8 hyperlinks"
Terminals (some terminals) support hyperlinks and it creates clickable links. For example ls -l --hyperlink=auto If you terminal supports it, you can click the names.

See here for more info: https://github.com/Alhadis/OSC8-Adoption/

It creates links in the output. You click them. It opens the file. That's pretty much it.