Skip to main content

OSC 11

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 11 sets or queries the terminal's default background color. This is the color displayed behind all text in the terminal window.

Syntax​

OSC 11 ; spec ST      Set default background color
OSC 11 ; ? ST Query current background color
Formal syntax
OSC11_set   = 0x1b, "]", "11", ";", color_spec, ( 0x07 | 0x1b, "\\" ) ;
OSC11_query = 0x1b, "]", "11", ";", "?", ( 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 background color:

OSC 11 ; 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 11 controls the VT100 text background color. The color specification uses the same X11 color syntax as OSC 4 and OSC 10.

The query form (OSC 11 ; ?) is one of the most widely used dynamic color queries. Applications such as Vim, Neovim, and tmux use it to detect the terminal's background color and determine whether a dark or light color scheme is in use. The luminance of the returned RGB value is compared against a threshold to decide the appropriate color palette for the application.

Changes made with OSC 11 take effect immediately and affect the entire terminal background. This includes areas where no text has been written (the "empty" portions of the screen).

note

Some terminals allow the user to lock their background color, preventing OSC 11 from modifying it. The query form may still work in such cases.

Examples​

# Set background to black
printf '\e]11;rgb:00/00/00\e\\'

# Set background to a dark blue
printf '\e]11;rgb:1a/1b/2e\a'

# Query current background color
printf '\e]11;?\e\\'

# Detect dark vs light mode by examining the response
# Response will be like: \e]11;rgb:0000/0000/0000\e\\
printf '\e]11;?\a'

Specifications​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesListed as IMPLEMENTED in escape_support.md:101
Bobcat??DynamicColors() enabled from v0.9.0, but actual OSC 10/11/12 handling is in TerminalCtrl library
contour✓v0.1.0Set/query default background color
foot✓YesQuery/set background color with alpha, osc.c:1398-1478
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✓YesSet/query background color via set_dynamic_color
Konsole✓YesBackgroundColor enum value 11 in src/session/Session.h:417, reportBackgroundColor in src/session/Session.cpp:991
mintty✓YesImplemented at termout.c:4701-4719, set/query default background color (also supports background images)
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 background color
st✓0.8.5Supports both set and query operations
terminology✓v1.5.0
VT100✗No
VTE✓YesOSC 11 (XTERM_SET_COLOR_TEXT_BG) handled in vteseq.cc
WezTerm✓YesOSC 11 TextBackgroundColor with query support - see wezterm-escape-parser/src/osc.rs:61,234-253,381-392,472
Windows Terminal✓YesSetBackgroundColor case via SetXtermColorResource/RequestXtermColorResource
xterm✓YesOSC 11 changes VT100 text background color (OSC_TEXT_BG=11 in ptyx.h:1019)
xterm.js✓4.16.0
Multiplexers
cy✓Yes
GNU Screen✓v.4.7.0
tmux✓2.6Set/query default background color
tuios✓v0.0.15
Zellij~v0.12.0Query only, setting not supported

See also​