Skip to content

OSC 10 / 11 / 12 / 17 / 19 — Dynamic Color Set / Query

SequenceOSC <code> ; rgb:R/G/B ST (set) · OSC <code> ; ? ST (query)
Otty support✓ 10 / 11 / 12 · ✓ 17 / 19 · OSC 13 / 14 parsed, not applied on macOS · OSC 15 / 16 / 18 parsed, not rendered (Tek 4014 is a dead protocol)

Description

Lets a program set or query one of the terminal's "named" colors at runtime — distinct from the 256-color palette (OSC 4) and from per-cell SGR colors.

CodeSlotOtty effect
10Text foregroundapplied to default-fg cells
11Text backgroundapplied to default-bg cells + window
12Cursor coloroverrides cursor-color config
13Mouse pointer fgstored, no visible effect on macOS
14Mouse pointer bgstored, no visible effect on macOS
15Tektronix foregroundstored, not rendered
16Tektronix cursorstored, not rendered
17Highlight (selection) backgroundoverrides selection-background
18Tektronix backgroundstored, not rendered
19Highlight (selection) foregroundoverrides selection-foreground

Query form (OSC <code> ; ? ST) replies in the canonical xterm format OSC <code> ; rgb:HHHH/HHHH/HHHH ST (16-bit per channel, replicated from 8 bits).

Accepted color formats

  • rgb:RR/GG/BB — 8-bit hex (xterm shorthand)
  • rgb:R/G/B — 4-bit hex shorthand (f/0/00xff 0x00 0x00)
  • rgb:RRRR/GGGG/BBBB — 16-bit canonical form (Otty truncates to high byte)
  • #RGB, #RRGGBB, #RRRGGGBBB, #RRRRGGGGBBBB

Reset pages

The reset companion sequences live at OSC 104 / 110-119.

Examples

bash
# Highlight the selection with a warm gold (kitty's "yellow on bright bg" style)
printf '\e]17;#665522\e\\'
printf '\e]19;#ffffe0\e\\'

# Switch the cursor to red while a debugger is attached, then restore
printf '\e]12;#ff5555\e\\'
# … run debugger …
printf '\e]112\e\\'   # OSC 112 — reset cursor color

# Query the current fg / bg
printf '\e]10;?\e\\\e]11;?\e\\'
# The reply lands on the shell's stdin — capture with:
#   printf '\e]10;?\e\\'; read -d $'\a' reply; echo "$reply"

# Try every code at once interactively:
otty features try change-color

Notes

  • OSC 10/11/12 affect every default-color cell on the next frame; pre-existing cells already painted with explicit SGR colors keep their color.
  • OSC 17/19 only affect the selection overlay — they do not change the SGR 48 / 38 cell colors.
  • OSC 13/14 (mouse pointer colors) are recorded but not applied — macOS has no way to recolor the mouse pointer, so the values are inert there.
  • Query replies travel back through the PTY as if the user typed them — they land on the shell's stdin. Use read (bash/zsh) or process_substitution (fish) to capture them.

Otty