Some support for hyperlinks like filenames and weblinks #4241
Replies: 2 comments 1 reply
-
More background on hyperlinks can be found at https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda Apparently, any terminal that supports ansi codes will gracefully degrade in the presence of hyperlinks, no fallback is needed. |
Beta Was this translation helpful? Give feedback.
-
The question is how to support this within clap. We are moving to user-supplied formatted strings in 4.x. Anything that is a |
Beta Was this translation helpful? Give feedback.
-
Hi all. One thing I learned recently was how to create hyperlinks in the terminal, like ls command can do. I use that functionality in my custom scripts currently. Maybe this hyperlink functionality could be optional for detected links or forcing on special formatted filenames in help messages in example. Just an idea, not even sure if that is a good one. A demonstration with a standard tool would be
ls --hyperlink
.Here is a test script one can use to test this. I tried to make it work on stdin instead, but that is not important for the discussion here.
hl
:Here is an example how I can do this with a shell script (Linux). Let's say we have a standard echo output with
echo -n backups
. It would just print the text. But If I output it as an argument to hl inhl $(echo n- backups)
, then it becomes clickable like a website hyperlink. And if there is a folder named "backups", then it would open with default application. Speaking of weblinks, this also works with https:// links:hl $(echo -n "https://rust-lang.org/")
.But hyperlinks has to be supported by the terminal. And I think some terminals already make detected weblinks clickable. But that is all of my knowledge about this topic. I am fairly new to it.
Beta Was this translation helpful? Give feedback.
All reactions