XTGETTCAP — Request terminfo capability (DCS + q ... ST)
Ask the terminal to report a terminfo capability value by its name — the runtime way to probe true-colour, RGB, OSC 52, etc.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1bP+q<HEX-NAME>;<HEX-NAME>...\x1b\\\033P+q<HEX-NAME>\033\\\eP+q<HEX-NAME>\e\\ESC P + q HEX[;HEX...] ESC \1b 50 2b 71 ... 1b 5cDescription
XTGETTCAP — xterm's terminfo-cap query, a DCS frame whose intermediate is `+` (0x2b) and final is `q` (0x71). The body is one or more terminfo capability names encoded as ASCII-hex (no separators inside a name, `;` between names). For example `RGB` becomes `524742`, `setrgbf` becomes `73657472676266`, `Smulx` (extended underline) becomes `536d756c78`. The terminal replies with one DCS per requested cap: `\x1bP1+r<HEX-NAME>=<HEX-VALUE>\x1b\\` on success, `\x1bP0+r<HEX-NAME>\x1b\\` if the cap is unknown. This is the canonical modern way `tmux`, `neovim`, `kitty`'s shell-integration, and `wezterm`'s `mux` discover feature support at runtime instead of trusting the `$TERM` string. xterm itself, kitty, wezterm, ghostty and tmux understand it; most other terminals return the 0+r 'unknown' reply for everything, which apps interpret as 'fall back to TERM-string heuristics'.
Spec citation: xterm-ctlseqs (XTGETTCAP, DCS + q Pt ST)
Examples
# Ask if the terminal advertises the RGB cap (hex of 'RGB' is 524742):\nstty -echo raw min 0 time 5\nprintf '\033P+q524742\033\\'\nIFS= read -r -t 1 -d '\\' REPLY; stty sane\necho "XTGETTCAP RGB reply: $REPLY"import sys\nname_hex = 'RGB'.encode().hex() # -> '524742'\nsys.stdout.write(f'\x1bP+q{name_hex}\x1b\\\\') # reply on stdinname := hex.EncodeToString([]byte("RGB"))\nfmt.Printf("\x1bP+q%s\x1b\\\\", name)const name = Buffer.from('RGB').toString('hex') // 524742\nprocess.stdout.write(`\x1bP+q${name}\x1b\\\\`)/* hex-encode the cap name first, e.g. 'RGB' -> "524742" */\nprintf("\x1bP+q524742\x1b\\\\"); fflush(stdout);Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- no
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- no
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- no
- Konsole
- no
- 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 | no | partial | no | no | yes | no | yes | yes | no | no | no | no |