^[control-codes live in libghostty-vt

Operating system commands

OSC 17 Highlight Background Color

Set and query the color of the background of selected text.

OSC 17 ; Pt ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51
xterm
Operating System Commands

OSC 17 ; Pt ST sets the color of the background of selected text, and OSC 17 ; ? ST asks what it is. OSC 117 puts it back as it started. It is one of xterm’s dynamic colors, and works as OSC 10 explains: Pt is any color X11 can parse, and a further ; in the same sequence moves on to color 18.

xterm uses the two highlight colors for a selection only in its highlight color mode, highlightColorMode. That mode is off unless both colors have been set to something other than the text’s own colors (charproc.c), so by default a selection is shown in reverse video and these colors are not used, though they are still kept and reported.

A default xterm starts it as the highlightColor resource, which is the foreground (charproc.c), so in the terminal the cases run in, set up as a default xterm, it is reported as rgb:0000/0000/0000.

libghostty-vt has no such color, and ignores OSC 17 and OSC 117, so the cases that ask are known differences.

Validation

OSC17-1: Ask for it

\e]17;?\a
|____|
reply \e]17;rgb:0000/0000/0000\a

OSC17-2: Change it

\e]17;#0080ff\a
\e]17;?\a
|____|
reply \e]17;rgb:0000/8080/ffff\a
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.