^[control-codes
live in libghostty-vt

Operating system commands

OSC 8 Hyperlink

View as Markdown

Make text a link, the way an anchor does in HTML.

OSC 8 ; Pp ; Pu ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51

OSC 8 ; Pp ; Pu ST starts a link to the URI Pu, and the text written after it is part of the link until OSC 8 ; ; ST, with an empty URI, ends it. The text looks as it would anyway; what changes is that a terminal can open the link when it is clicked, as ls --hyperlink and many compilers’ error messages expect. Pp is a list of key=value parameters separated by :. The one in use is id: cells with the same id and URI are one link, even when what is between them, such as an editor’s border, is not.

It came from GNOME Terminal and has spread to most terminals, but not to xterm. A default xterm has no OSC 8 (the OSC numbers it knows), ignores it, and shows the text as plain text. The cases follow xterm.

libghostty-vt keeps the link with each cell it covers, which is what the link word in an attr line checks. A link is not part of SGR: CSI 0 m does not end it, and nor does a new line; only another OSC 8 does. The case that checks for the link is a known difference.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984NoOSC is not among the controls it recognizes (§4.2)
VT510manual, 1st ed., 1993Noignores an OSC string (chapter 4)
xtermpatch 412, xterm-411aNo
libghostty-vt0f171f6YesOSC8-2: keeps the link with each cell
Konsole26.11.70, a24c3d71Partlyoff by default, behind the AllowEscapedLinks profile setting; discards id
ConEmubuild 230724, its documentationNonot in ConEmu’s list, ANSI escape codes

Validation

OSC8-1: The text appears as usual

\e]8;;https://example.com/\e\\
AB
\e]8;;\e\\
C
|ABC___|
cursor 1,4
reply none

OSC8-2: A default xterm makes no link

\e]8;id=1;https://example.com/\a
A
\e]8;;\a
B
|AB____|
attr 1,1 -link

OSC8-3: After the end there is no link

\e]8;;https://example.com/\a
A
\e]8;;\a
B
|AB____|
attr 1,2 -link
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.