wire / terminal-osc / 4

OSC 4 — Set / query color palette entry

OSC 4 ; c ; spec ST sets palette color number c to spec, where spec is an X11 color name or rgb:RR/GG/BB form. OSC 4 ; c ; ? ST queries the current value of palette entry c; the terminal replies with OSC 4 ; c ; rgb:RRRR/GGGG/BBBB ST. Lets a program recolor or read any of the 256 indexed colors at runtime.

terminal-osc kind control-sequence status de-facto verification verified tier B terminal-escape@1

aka: set color palette · query color palette · OSC 4 · ESC ] 4 · set ANSI color

frame

OSC introducer: \x1b] ESC ] (0x1B 0x5D)

terminator (ST|BEL): ST \x1b\ · BEL \x07

parameters / subcommands

idnamebytes (ST)meaning
set Set color \x1b]4;1;rgb:ff/00/00\x1b\ OSC 4 ; c ; spec ST sets palette index c (0–255) to spec. spec is an X11 color name (e.g. 'red') or an rgb:RR/GG/BB / #RRGGBB form. Multiple c ; spec pairs may be concatenated in one sequence.
query Query color \x1b]4;1;?\x1b\ OSC 4 ; c ; ? ST asks the terminal for the current value of palette index c. The terminal replies with OSC 4 ; c ; rgb:RRRR/GGGG/BBBB ST (note 16-bit-per-channel form in the reply).

gotchas


provenance

per-fact attribution:

see also

agent: curl -H 'accept: application/json' wire.phall.io/terminal-osc/4 or /terminal-osc/4.json