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");Used in
Real-world tools that emit this sequence — anchors the bytes to commands you've already used.
- neovim cursor-shape themesthemes set `:hi Cursor guibg=...` then drive OSC 12 via `:set guicursor` mappings so the cursor recolours per insert / normal / visual mode without redrawing the screen
- fish_vi_cursorfish's vi-mode emits `\x1b]12;<colour>\x07` on mode change so the cursor flashes orange in command mode, white in insert — surfaces vi state at a glance
- kitty, wezterm per-mode cursor overrideskitty's `cursor_text_color` and wezterm's `colors.cursor_fg/bg` accept dynamic OSC 12 from the running shell — `tmux` / `nvim` can override the terminal default per pane on entry
- tmux `set -g cursor-color`tmux passes through OSC 12 from the active pane, so a per-pane cursor colour reflects the foreground program (vim red, fish white) instead of a single terminal-wide colour
- terminator, konsole config-file cursor colourGTK terminals read the cursor colour from a profile file, but accept OSC 12 at runtime as a per-session override — useful for SSH sessions that should signal a remote host visually
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
- yes
- GNU screen
- yes
| 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 | yes | yes |