OSC 10 / 11 — Set default foreground / background color
Set the terminal's default foreground (OSC 10) or background (OSC 11) color, or query the current value.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b]10;#RRGGBB\x07 (set fg) \x1b]11;#RRGGBB\x07 (set bg)\033]10;#RRGGBB\007 / \033]11;#RRGGBB\007\e]10;#RRGGBB\a / \e]11;#RRGGBB\aESC ] 10 ; COLOR BEL / ESC ] 11 ; COLOR BEL1b 5d 31 30 3b ... 07 / 1b 5d 31 31 3b ... 07Description
OSC 10 sets the terminal's default foreground color, OSC 11 the background. The color argument accepts the same forms xterm parses: `#RRGGBB`, `#RGB`, `rgb:RRRR/GGGG/BBBB`, or X11 names like `cornflowerblue`. Passing `?` as the value (`\x1b]10;?\x07`) makes the terminal reply with the current color in the same syntax — used by tools like vim's `'background'` autodetect to choose a light or dark colorscheme. Reset to the terminal default with OSC 110 (fg) / OSC 111 (bg).
Spec citation: xterm-ctlseqs (OSC 10 / 11 / 110 / 111)
Examples
printf '\033]11;#1e1e2e\007' # set bg to deep navy\nprintf '\033]11;?\007' # query current bgimport sys; sys.stdout.write('\x1b]10;#cdd6f4\x07')fmt.Print("\x1b]10;#cdd6f4\x07")process.stdout.write('\x1b]10;#cdd6f4\x07')printf("\x1b]10;#cdd6f4\x07");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- partial
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | partial | yes | yes | no | yes | yes | yes | yes | yes | yes | no | no |
Related sequences
In the family cookbook
SGR cookbook · 5. OSC palette override — repaint the slot itself