Skip to main content

OSC 12

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

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

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesListed 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.0Set/query cursor color
foot✓YesQuery/set cursor color, osc.c:1398-1484
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✓YesSet/query cursor color via set_dynamic_color
Konsole✓YesCursorColor enum value 12 in src/Vt102Emulation.h:191, handled in src/Vt102Emulation.cpp:1157-1166
mintty✓YesImplemented at termout.c:4720, set/query cursor 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-2.0Compile flag NO_CURSORCOLOR can disable
st✓0.8.5Supports both set and query operations
terminology✓v1.5.0
VT100✗No
VTE✓YesOSC 12 (XTERM_SET_COLOR_CURSOR_BG) handled in vteseq.cc
WezTerm✓YesOSC 12 TextCursorColor with query support - see wezterm-escape-parser/src/osc.rs:62,234-253,381-392,473
Windows Terminal✓YesSetCursorColor case via SetXtermColorResource/RequestXtermColorResource
xterm✓YesOSC 12 changes text cursor color (OSC_TEXT_CURSOR=12 in ptyx.h:1020)
xterm.js✓4.16.0
Multiplexers
cy✗NoCode exists but is commented out
GNU Screen✗No
tmux✓3.3Set/query cursor color
tuios✓v0.0.15
Zellij✗NoExplicitly unimplemented in code

See also​