Skip to main content

OSC 10

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Experimental

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
Formal syntax
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​

ParameterDescriptionDefault
specColor 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​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesListed 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.0Set/query default foreground color
foot✓YesQuery/set foreground color, osc.c:1398-1458
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✓YesSet/query foreground color via set_dynamic_color
Konsole✓YesTextColor enum value 10 in src/session/Session.h:416, reportForegroundColor in src/session/Session.cpp:986
mintty✓YesImplemented at termout.c:4700, set/query default foreground color
mlterm✓rel-3_0_7
PuTTY✗NoNot implemented in do_osc function
Rio✓v0.0.28Supports both setting and querying with '?'
rxvt-unicode✓rxvt-unicode-7.0Supports querying and setting default foreground color
st✓0.8.5Supports both set and query operations
terminology✓v1.5.0
VT100✗No
VTE✓YesOSC 10 (XTERM_SET_COLOR_TEXT_FG) handled in vteseq.cc
WezTerm✓YesOSC 10 TextForegroundColor with query support - see wezterm-escape-parser/src/osc.rs:60,234-253,381-392,471
Windows Terminal✓YesSetForegroundColor case via SetXtermColorResource/RequestXtermColorResource
xterm✓YesOSC 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.6Set/query default foreground color
tuios✓v0.0.15
Zellij~v0.12.0Query only, setting not supported

See also​