Skip to main content
ansicode

OSC 19 — Set highlight (selection) foreground colour

Change the foreground colour the terminal uses for selected (highlighted) text.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b]19;#RRGGBB\x07 (set) \x1b]19;?\x07 (query)
\\033[\033]19;#RRGGBB\007
\\e[\e]19;#RRGGBB\a
ESC [ESC ] 19 ; COLOR BEL
hex1b 5d 31 39 3b ... 07

Description

OSC 19 sets the foreground colour used for selected (mouse-highlighted) text — the glyph colour you see on top of the OSC 17 highlight band. Colour syntax matches OSC 10 / 11 / 12 / 17: `#RRGGBB`, `#RGB`, `rgb:RRRR/GGGG/BBBB`, X11 names. Sending `?` queries the current value (the terminal replies with `\x1b]19;rgb:...\x07`). Like OSC 17 this is historically xterm-specific and most modern terminals route selection colours through their theme config rather than runtime OSC; check the support matrix before relying on it. Use the matching reset `\x1b]119\x07` to restore the user's configured highlight fg.

Spec citation: xterm-ctlseqs (OSC 19 / 119)

Examples

bash
printf '\033]19;#cdd6f4\007'   # set selection fg\nprintf '\033]19;?\007'         # query
python
import sys; sys.stdout.write('\x1b]19;#cdd6f4\x07')
go
fmt.Print("\x1b]19;#cdd6f4\x07")
javascript
process.stdout.write('\x1b]19;#cdd6f4\x07')
c
printf("\x1b]19;#cdd6f4\x07");

Terminal support

xterm
yes
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
no
Windows Terminal
no
cmd.exe / ConPTY
no
kitty
no
alacritty
no
WezTerm
partial
Ghostty
no
GNOME Terminal
partial
Konsole
partial
tmux
no
GNU screen
no

Related sequences