-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Feature] Enable OSC8 hyperlinks for line numbers or highlighted line numbers #2158
Comments
Thanks for the suggestion, it sounds interesting :) I tried your Python script on Linux Mint with I have a few questions, if I may. For a clickable line number, what should the URI look like (assuming the default We would also need to consider how it would interact with when P.S. Thanks for the sponsorship, glad you find our work on |
Unfortunately the OSC8 URIs do not support launching arbitrary commands. macOS does allow easy and arbitrary registration of URI scheme handlers, e.g.:
So you can Unfortunately, Regarding stdin, I think it's fine to require |
I write to support this request. I would be happy with the file name in the header being an OSC8 hyperlink. This would also serve as a test case for the suggested line number feature, and the usual |
Huh, interesting. This seems like a pretty useful feature! I might take a crack at it once my finals are over for the semester if I have the time :) |
Some terminals and editors do support I'd also note that file: URLs are useful for editors in the terminal if you use a terminal that supports it! Here's what it looks like in kitty for me, using Screen.Recording.2024-09-26.at.10.54.32.AM.mov |
While iTerm may have been the first, lots of terminals now support OSC8 hyperlinks. This is a custom escape handler that lets text be clickable hypertext, effectively.
Supporting this would only mean adding some escape characters and a URI to each line number that's printed, to allow them to be ⌘-Clicked to open in the editor of choice.
Most of this is irrelevant if using a non-GUI editor (vim, emacs, etc) but relevant on at least macOS and likely other OSes if they support custom URI handlers.
Proposal
I propose the following additional flags for bat:
--osc8
will cause every line number to be a clickable link--osc8-highlight
will be the same, but only for highlighted lines--osc8-scheme
is an optional flag, defaults tofile://
, which informs Bat as to which URI to printbat
options, none of the above have any effectFor completeness, I do not need this as a feature (iTerm2 lets you ⌘-Click paths to open them automagically) but I may as well suggest it.
--osc8
will cause every file name to be a clickablefile://
linkTechnical Details
I'm not a Rustacean yet, but here's a function that creates OCS8 links in Python.
Sponsorship
Not that this grants me any special treatment, but I'm a sponsor for all of the maintainers of
bat
❤️💵The text was updated successfully, but these errors were encountered: