Skip to content

XTGETTCAP: Request Termcap/Terminfo String

Status: xterm.

XTGETTCAP asks the terminal for the value of a terminfo capability by name. It lets an application learn what the terminal thinks its terminfo says without a terminfo database on the local machine, which matters over SSH, in containers, and for terminals whose entry is not installed.

Syntax

DCS + q hex-name [ ; hex-name ]… ST          request
DCS 1 + r hex-name = hex-value [ ; … ] ST     reply, valid
DCS 0 + r [ hex-name ] ST                     reply, invalid

Names and values are hex-encoded ASCII: TN is 544e, Co is 436f, RGB is 524742. Several names may be requested at once; xterm answers all of them in one reply and reports 0 if any name is unknown. Other terminals may answer each name separately or omit unknown names from a 1 reply, so parse the reply by name rather than by position.

xterm gates this behind allowTcapOps, which is true by default but frequently disabled by distributions.

Useful names

Name Meaning Why ask
TN Terminal name The terminfo entry the terminal wants; xterm answers with its termName
Co / colors Number of colors 256 versus 16777216
RGB Direct color capability Terminfo's spelling of truecolor support
Tc Truecolor (tmux convention) The other spelling; ask for both
Smulx Styled underline CSI 4 : Ps m support
Setulc Underline color CSI 58 ; … m support
Sync Synchronized output Mode 2026 as a terminfo string
Ss / Se Set/reset cursor style DECSCUSR support
kitty-query-* kitty-specific Answered only by kitty; see its docs

Key-related names (kf1, kcuu1, …) are also useful: they tell an application the encoding the terminal will actually send.

Probe

# TN ; Co ; RGB
tools/query '\033P+q544e;436f;524742\033\\'

Decode the reply with xxd -r -p on each hex-name=hex-value pair.

Sources

Compatibility

Feature support by terminal. Imported claims have not been reverified; unknown is not unsupported.
Feature / stable ID Alacritty Apple Terminal ConPTY (conhost) Contour DomTerm foot Ghostty iTerm2 kitty Konsole mintty mlterm PuTTY Revenant RLogin st tmux rxvt-unicode VTE wayst WezTerm Windows Terminal xterm xterm.js
XTGETTCAP
dcs-xtgettcap
Unknown Unknown Unknown SupportedImported · unverified Unknown SupportedImported · unverified SupportedImported · unverified Unknown SupportedImported · unverified Unknown SupportedImported · unverified Unknown Unknown Partial Unknown Unknown Unknown Unknown Unknown Unknown SupportedImported · unverified UnknownImported · unverified SupportedImported · unverified UnknownImported · unverified