Open NDagestad opened 4 weeks ago
Hi @NDagestad, this is great; I came to the repo precisely in order to look to see whether anyone had started work on this feature.
Currently, your PR only supports file://
links. I'd like to suggest following e.g. ripgrep and delta
by making the hyperlink format configurable, perhaps by adding an option --hyperlink-format
as ripgrep does.
This will allow tree
to create links that open in a specific editor/IDE with whatever behavior is desirable for that editor/IDE (e.g., opening the file in the correct project workspace). It also allows users to register custom URL protocols with their OS to implement arbitrary on-click behavior and/or to route the click to an arbitrary HTTP service (personal project e.g.), etc.
See
I am not quite sure how I feel about changing the scheme like that, I'll play a bit around with it this weekend to make up my mind about it. 🤔 And also maybe email the author, because I am not sure if contributing to the github is the proper way to contribute to tree.
In something like tree where sometimes the list can be very long and getting the path of a file out of the tree output is not necessarily trivial, having terminal hyperlink is really nice !
I have used a variation of this PR for a few month now without any issues (but I reworked it a bit before making the PR so a bug could have sneaked in there).
Some info on terminal hyperlinks (OSC 8 escape sequence) https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda https://github.com/Alhadis/OSC8-Adoption