OSC 12
OSC 12 sets or queries the terminal's cursor color. This controls the color of the text cursor (caret) independently from the foreground and background colors.
Syntax
OSC 12 ; spec ST Set cursor color
OSC 12 ; ? ST Query current cursor color
OSC12_set = 0x1b, "]", "12", ";", color_spec, ( 0x07 | 0x1b, "\\" ) ;
OSC12_query = 0x1b, "]", "12", ";", "?", ( 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 cursor color:
OSC 12 ; 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 12 controls the text cursor color. The color specification uses the same X11 color syntax as OSC 4, OSC 10, and OSC 11.
The cursor color determines how the text cursor is rendered. For block cursors, this is the fill color. For bar and underline cursors, this is the stroke color. The exact rendering depends on the terminal's cursor style setting.
This sequence is useful for applications that want to change the cursor appearance to indicate mode changes (e.g., different cursor colors for insert vs. normal mode in a vi-style editor) or to ensure the cursor is visible against a custom background color.
Examples
# Set cursor color to red
printf '\e]12;rgb:ff/00/00\e\\'
# Set cursor color to green
printf '\e]12;rgb:00/ff/00\a'
# Query current cursor color
printf '\e]12;?\e\\'
# Use different cursor colors for vi modes
# (example: red for normal mode, green for insert mode)
printf '\e]12;rgb:ff/00/00\a' # normal mode
printf '\e]12;rgb:00/ff/00\a' # insert mode
Specifications
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Listed as IMPLEMENTED in escape_support.md:102 |
| Bobcat | ? | ? | DynamicColors() enabled from v0.9.0, but actual OSC 10/11/12 handling is in TerminalCtrl library |
| contour | ✓ | v0.1.0 | Set/query cursor color |
| foot | ✓ | Yes | Query/set cursor color, osc.c:1398-1484 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✓ | Yes | Set/query cursor color via set_dynamic_color |
| Konsole | ✓ | Yes | CursorColor enum value 12 in src/Vt102Emulation.h:191, handled in src/Vt102Emulation.cpp:1157-1166 |
| mintty | ✓ | Yes | Implemented at termout.c:4720, set/query cursor 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-2.0 | Compile flag NO_CURSORCOLOR can disable |
| st | ✓ | 0.8.5 | Supports both set and query operations |
| terminology | ✓ | v1.5.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | OSC 12 (XTERM_SET_COLOR_CURSOR_BG) handled in vteseq.cc |
| WezTerm | ✓ | Yes | OSC 12 TextCursorColor with query support - see wezterm-escape-parser/src/osc.rs:62,234-253,381-392,473 |
| Windows Terminal | ✓ | Yes | SetCursorColor case via SetXtermColorResource/RequestXtermColorResource |
| xterm | ✓ | Yes | OSC 12 changes text cursor color (OSC_TEXT_CURSOR=12 in ptyx.h:1020) |
| xterm.js | ✓ | 4.16.0 | |
| Multiplexers | |||
| cy | ✗ | No | Code exists but is commented out |
| GNU Screen | ✗ | No | |
| tmux | ✓ | 3.3 | Set/query cursor color |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✗ | No | Explicitly unimplemented in code |
See also
- OSC 10 — Set/Query Default Foreground Color — Sets or queries the default foreground color
- OSC 11 — Set/Query Default Background Color — Sets or queries the default background color
- OSC 4 — Change/Query Color Palette — Sets or queries indexed palette colors