OSC 11
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
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
| 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 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).
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
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Listed 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.0 | Set/query default background color |
| foot | ✓ | Yes | Query/set background color with alpha, osc.c:1398-1478 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✓ | Yes | Set/query background color via set_dynamic_color |
| Konsole | ✓ | Yes | BackgroundColor enum value 11 in src/session/Session.h:417, reportBackgroundColor in src/session/Session.cpp:991 |
| mintty | ✓ | Yes | Implemented at termout.c:4701-4719, set/query default background color (also supports background images) |
| 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 background color |
| st | ✓ | 0.8.5 | Supports both set and query operations |
| terminology | ✓ | v1.5.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | OSC 11 (XTERM_SET_COLOR_TEXT_BG) handled in vteseq.cc |
| WezTerm | ✓ | Yes | OSC 11 TextBackgroundColor with query support - see wezterm-escape-parser/src/osc.rs:61,234-253,381-392,472 |
| Windows Terminal | ✓ | Yes | SetBackgroundColor case via SetXtermColorResource/RequestXtermColorResource |
| xterm | ✓ | Yes | OSC 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.6 | Set/query default background color |
| tuios | ✓ | v0.0.15 | |
| Zellij | ~ | v0.12.0 | Query only, setting not supported |
See also
- OSC 10 — Set/Query Default Foreground Color — Sets or queries the default foreground (text) 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