^[control-codes live in libghostty-vt

Operating system commands

OSC 104 Reset Color Palette

Put palette colors back as they started.

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

OSC 104 ; Pc ST puts palette color Pc back as the terminal started it, undoing OSC 4. It takes any number of colors, OSC 104 ; 1 ; 2 ST, and with none, OSC 104 ST, resets every one (ResetAnsiColorRequest).

xterm reads the numbers in turn and stops at the first that is not a number, so OSC 104 ; 1 ; x ; 2 ST resets color 1 and leaves color 2 alone. A number past the palette is skipped (ResetOneAnsiColor).

With no number xterm resets more than the palette: it runs over every color slot it has, and the slots after the 256 palette colors hold the five special colors, so they are reset too. Those also have a reset of their own, OSC 105, and can be reset one by one here as palette numbers 256 to 260.

DECSTR and RIS reset the palette as well, as the OSC 4 page shows.

libghostty-vt resets the colors named, and with none, the whole palette. It differs from xterm when the list has something in it that is not a number: it skips that and goes on, and a list with no number left in it resets the whole palette, as an empty one does. Its source says this follows kitty on purpose. It also leaves the special colors alone, having none. Those cases are known differences.

Validation

OSC104-1: Reset one color

\e]4;1;red;2;blue\a
\e]104;1\a
\e]4;1;?;2;?\a
|____|
reply \e]4;1;rgb:cdcd/0000/0000\a\e]4;2;rgb:0000/0000/ffff\a

OSC104-2: Several

\e]4;1;red;2;blue;3;green\a
\e]104;1;3\a
\e]4;1;?;2;?;3;?\a
|____|
reply \e]4;1;rgb:cdcd/0000/0000\a\e]4;2;rgb:0000/0000/ffff\a\e]4;3;rgb:cdcd/cdcd/0000\a

OSC104-3: Reset them all

\e]4;1;red;2;blue\a
\e]104\a
\e]4;1;?;2;?\a
|____|
reply \e]4;1;rgb:cdcd/0000/0000\a\e]4;2;rgb:0000/cdcd/0000\a

OSC104-4: An empty list is all of them too

\e]4;1;red;2;blue\a
\e]104;\a
\e]4;1;?;2;?\a
|____|
reply \e]4;1;rgb:cdcd/0000/0000\a\e]4;2;rgb:0000/cdcd/0000\a

OSC104-5: Something not a number stops the list

\e]4;1;red;2;blue\a
\e]104;1;x;2\a
\e]4;1;?;2;?\a
|____|
reply \e]4;1;rgb:cdcd/0000/0000\a\e]4;2;rgb:0000/0000/ffff\a

OSC104-6: So nothing is reset

\e]4;1;red\a
\e]104;x\a
\e]4;1;?\a
|____|
reply \e]4;1;rgb:ffff/0000/0000\a

OSC104-7: With no number, the special colors too

\e]5;0;red\a   # the color for bold
\e]104\a
\e]5;0;?\a
|____|
reply \e]5;0;rgb:0000/0000/0000\a
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.