I stumbled across this page https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda which lists a example to print a string that will be interpreted as a hyperlink in a terminal emulator
printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
which results in the output
This is a link
on the terminal and is clickable to get to the website.
I was trying to replicate the same thing via my Kotlin application by using both
println("""\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'""")
System.out.println("\\e]8;;http://example.com\\e\\\\This is a link\\e]8;;\\e\\\\\\n'")
but all I get is
\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
as the output.
Does anyone know how to achieve the same in Kotlin?
Kotlin does not interpret escape sequences (like \e) in regular strings or triple-quoted strings.
you should use the actual escape character, represented as \u001B.
try something like this
\u001B]8;;http://example.com\u001B\\This is a link\u001B]8;;\u001B\\\n