0

On Gnome shell when you type links like https://www.stackoverflow.com, it's underlined and you can click it to open the link in a web browser.

How can we use echo to make underlined text, that when you hover over it, it shows a small box with text for maybe some information?

I just know how to underline: echo -e "\033[4m Underlined text \033[0m"

1
  • I'm pretty sure that is not possible from a shell. – DavidPostill Feb 21 at 16:39
0

You can't, because terminal emulators all emulate dumb terminals from the 1970's that didn't have mice. So the special "escape codes" that tell the terminal [emulator] to make text brighter or underlined or whatever, don't contain a code for specifying "this is a clickable link", or "here's some hover text / tooltip to display if someone hovers their mouse pointer over this text".

Modern terminal emulators that let you click on URLs aren't being told by the shell that these are URLs. Nothing is sending escape codes to tell the terminal [emulator] that this should be treated like a clickable URL. Instead, the modern emulator is just watching the stream of text it's displaying, and looking for anything that looks like a URL, and making it clickable on its own accord.

One could imagine that someone could come up with a new anachronistic terminal type to "emulate", and as part of that create escape codes for things like hover text / tooltips, and then add support for that stuff in the rest of the terminal software infrastructure, like termcap/terminfo, the "curses" library, etc., and encourage other open source projects like bash and zsh and emacs and vi to support it, but I don't think anyone's done that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.