OSC 12 — Set cursor colour (and query)
Override the terminal's cursor colour, or query the current value via the OSC reply.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b]12;#RRGGBB\x07 (set) \x1b]12;?\x07 (query)\033]12;#RRGGBB\007\e]12;#RRGGBB\aESC ] 12 ; COLOR BEL1b 5d 31 32 3b ... 07Description
OSC 12 sets the colour of the text cursor (the block / bar / underline drawn at the input position). The colour argument accepts the same syntaxes as OSC 10 / 11: `#RRGGBB`, `#RGB`, `rgb:RRRR/GGGG/BBBB`, or X11 colour names. Sending `?` instead of a colour (`\x1b]12;?\x07`) makes the terminal reply with the current cursor colour using the same syntax — used by themes and `:set background=...` autodetect tools to query the live palette. Reset the cursor colour back to the user's terminal default with OSC 112 (`\x1b]112\x07`). Distinct from cursor SHAPE (`\x1b[? q` — DECSCUSR) and cursor VISIBILITY (`\x1b[?25h/l`), which control glyph and on/off — OSC 12 only changes the colour.
Spec citation: xterm-ctlseqs (OSC 12 / 112)
Examples
printf '\033]12;#f38ba8\007' # set cursor to pink\nprintf '\033]12;?\007' # query current cursor colourimport sys; sys.stdout.write('\x1b]12;#f38ba8\x07')fmt.Print("\x1b]12;#f38ba8\x07")process.stdout.write('\x1b]12;#f38ba8\x07')printf("\x1b]12;#f38ba8\x07");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- partial
- iTerm2
- yes
- Windows Terminal
- partial
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | partial | yes | partial | no | yes | yes | yes | yes | yes | yes | no | no |