I have a ruby terminal script that I would like to print out hyperlinks. I achieve that like so:
puts("\e]8;;https://example.com\aThis is a link\e]8;;\a")
This works perfectly fine in a "normal" terminal (gnome-terminal btw) window.
But I need to run this script within GNU screen
, where the escape-sequence simply has no effect. Other sequences (like colors for example) work fine, the hyperlink one (which according to the source might be a gnome-terminal-only thing) doesn't. (screen
is running inside gnome-terminal)
How can I get screen
to acknowledge my link sequence and display it properly?
Best Answer
You can pass through some text to the terminal
screen
itself runs in by putting it inside anESC P
,ESC \
pair (\033P%s\033\\
in printf format).So you should bracket inside
\eP..\e\\
pairs all the parts of the sequence, except for the text which will appear on the screen ("This is a link"
):Or, from C:
Putting the replacement text too inside
\eP..\e\\
may result in screen losing track of the cursor position.This is documented in the GNU screen manual:
The "string" should should be terminated with a
ST
("string terminator") escape, ie.\e\\
-- thence\eP..\e\\
.