OSC 10
OSC 10 sets or queries the terminal's default foreground (text) color. This is the color used for text that has not been explicitly colored with SGR attributes.
Syntax
OSC 10 ; spec ST Set default foreground color
OSC 10 ; ? ST Query current foreground color
OSC10_set = 0x1b, "]", "10", ";", color_spec, ( 0x07 | 0x1b, "\\" ) ;
OSC10_query = 0x1b, "]", "10", ";", "?", ( 0x07 | 0x1b, "\\" ) ;
color_spec = "rgb:", hex, "/", hex, "/", hex ;
hex = hex_digit, hex_digit, [ hex_digit, hex_digit ] ;
hex_digit = digit | "a" | "b" | "c" | "d" | "e" | "f"
| "A" | "B" | "C" | "D" | "E" | "F" ;
digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;Parameters
| Parameter | Description | Default |
|---|---|---|
spec | Color specification in X11 format (e.g., rgb:RR/GG/BB) or ? to query | (required) |
Response
When queried with ?, the terminal responds with the current foreground color:
OSC 10 ; rgb:RRRR/GGGG/BBBB ST
The response uses 16-bit color components (four hex digits per channel).
Description
Per the XTerm control sequences documentation, OSC 10 controls the VT100 text foreground color, also known as the "dynamic color" for the default foreground. The color specification uses the same X11 color syntax as OSC 4, most commonly rgb:RR/GG/BB.
The query form (OSC 10 ; ?) is commonly used by applications to detect the terminal's current color scheme. By querying both OSC 10 (foreground) and OSC 11 (background), an application can determine whether the terminal is using a light or dark theme and adapt its output accordingly.
Changes made with OSC 10 take effect immediately and affect all text rendered with the default foreground color. Text that has been explicitly colored with SGR sequences is not affected.
Examples
# Set foreground to white
printf '\e]10;rgb:ff/ff/ff\e\\'
# Set foreground to a light gray
printf '\e]10;rgb:cc/cc/cc\a'
# Query current foreground color
printf '\e]10;?\e\\'
# Detect dark/light theme by querying background color
# (parse the response to determine brightness)
printf '\e]10;?\a'
Specifications
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Listed as IMPLEMENTED in escape_support.md:100 |
| Bobcat | ? | ? | DynamicColors() enabled from v0.9.0, but actual OSC 10/11/12 handling is in TerminalCtrl library |
| contour | ✓ | v0.1.0 | Set/query default foreground color |
| foot | ✓ | Yes | Query/set foreground color, osc.c:1398-1458 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✓ | Yes | Set/query foreground color via set_dynamic_color |
| Konsole | ✓ | Yes | TextColor enum value 10 in src/session/Session.h:416, reportForegroundColor in src/session/Session.cpp:986 |
| mintty | ✓ | Yes | Implemented at termout.c:4700, set/query default foreground color |
| mlterm | ✓ | rel-3_0_7 | |
| PuTTY | ✗ | No | Not implemented in do_osc function |
| Rio | ✓ | v0.0.28 | Supports both setting and querying with '?' |
| rxvt-unicode | ✓ | rxvt-unicode-7.0 | Supports querying and setting default foreground color |
| st | ✓ | 0.8.5 | Supports both set and query operations |
| terminology | ✓ | v1.5.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | OSC 10 (XTERM_SET_COLOR_TEXT_FG) handled in vteseq.cc |
| WezTerm | ✓ | Yes | OSC 10 TextForegroundColor with query support - see wezterm-escape-parser/src/osc.rs:60,234-253,381-392,471 |
| Windows Terminal | ✓ | Yes | SetForegroundColor case via SetXtermColorResource/RequestXtermColorResource |
| xterm | ✓ | Yes | OSC 10 changes VT100 text foreground color (OSC_TEXT_FG=10 in ptyx.h:1018) |
| xterm.js | ✓ | 4.16.0 | |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✗ | No | |
| tmux | ✓ | 2.6 | Set/query default foreground color |
| tuios | ✓ | v0.0.15 | |
| Zellij | ~ | v0.12.0 | Query only, setting not supported |
See also
- OSC 11 — Set/Query Default Background Color — Sets or queries the default background color
- OSC 12 — Set/Query Cursor Color — Sets or queries the cursor color
- OSC 4 — Change/Query Color Palette — Sets or queries indexed palette colors