Skip to main content

XTVERSION

AI-Generated Content
This page was generated with the assistance of AI and may contain inaccuracies. It is intended as a placeholder for future human verification. If you spot issues ahead of its initial review, please report them on GitHub!
Experimental

XTVERSION is an XTerm extension that queries the terminal for its name and version string. The request is a CSI sequence, but the response is a DCS string, making this a hybrid sequence that spans both CSI and DCS categories.

Syntax​

CSI > 0 q            XTVERSION request
DCS > | text ST XTVERSION response
Formal syntax
(* Request *)
XTVERSION-request  = 0x1b, "[", ">", [ "0" ], "q" ;

(* Response *)
XTVERSION-response = 0x1b, "P", ">", "|", text, 0x1b, "\\" ;
text = printable-char, { printable-char } ;
printable-char = ? any printable ASCII character (0x20..0x7E) ? ;

Response​

The terminal responds with a DCS string containing a free-form text identifier. The format varies by terminal:

TerminalExample response
XTermDCS > | XTerm(370) ST
footDCS > | foot(1.16.2) ST
KittyDCS > | kitty(0.26.5) ST
WezTermDCS > | WezTerm 20240203-110809-5046fc22 ST
tmuxDCS > | tmux 3.4 ST
ContourDCS > | contour(0.4.3.6456) ST

Description​

XTVERSION provides a straightforward way for applications to identify which terminal emulator (and version) they are running under. Unlike DA1 and DA2, which report VT-level compatibility codes, XTVERSION returns a human-readable name and version string.

The request CSI > q (or equivalently CSI > 0 q) was introduced in XTerm patch 230. Despite the request being a CSI sequence, the response uses a DCS envelope (DCS > | ... ST), which is unusual among terminal query/response pairs.

Comparison with DA2​

DA2 (CSI > c) also provides terminal identification, but it uses numeric codes that require a lookup table to interpret. XTVERSION provides the terminal name directly as text, making it simpler for scripts and applications to parse.

Use cases​

  • Feature detection: Identify the terminal to enable or disable features known to work (or not work) in specific terminals or versions.
  • Bug workarounds: Apply version-specific workarounds by parsing the version number from the response.
  • Diagnostics: Log or display the terminal identity for debugging purposes.

Caveats​

Not all terminals implement XTVERSION. Applications should use a timeout when waiting for the response, as terminals that do not recognize the sequence will simply not reply. Running inside a multiplexer like tmux may also affect the response -- tmux responds with its own identity rather than forwarding the query to the outer terminal.

Examples​

# Query terminal version
printf '\e[>q'

# Query with explicit zero parameter
printf '\e[>0q'

# Read the response (in a script)
# The response arrives as: ESC P > | <name>(<version>) ESC \

Specifications​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✗No
Bobcat✓0.9.0SetDeviceId() sets terminal name/version response. Added in commit 0eac0f8 (2025-01-15) for 'Extended device attributes (CSI q <) response'.
contour✓v0.1.0XTVERSION (CSI > 0 q) implemented in Functions.h line 618 and Screen.cpp line 3947-3949, returns terminal name and version
foot✓1.7.0Replies with DCS>|foot(major.minor.patch)ST
Ghostty✓v1.0.0CSI > q
iTerm2✓YesCSI > 0 q terminal version query supported
Kitty✓0.21.2
Konsole✓YesResponds to CSI > q with terminal identification
mintty✓YesXTVERSION (CSI > q) implemented at src/termout.c:3144-3146
mlterm✓3.9.2Responds with 'DCS>|mlterm(version)ST'
PuTTY✗No
Rio✓v0.2.33
rxvt-unicode✓1.2Via CSI > c (secondary DA) - reports 'U' for urxvt with version info
st✗No
terminology✓v0.1.0Reports as VT420 with version 337
VT100✗No
VTE✗NoMentioned in terminfo but no handler found in code
WezTerm✓YesTerminal version response supported
Windows Terminal✗No
xterm✓xterm-230CSI > 0 q - Report xterm name and version (XTVERSION)
xterm.js✓YesIn master, not yet released
Multiplexers
cy✗No
GNU Screen✗NoOnly DA1 (CSI c) is supported, not DA2 (CSI > c)
tmux✓3.2Responds to CSI > q primary device attributes
tuios✗NoOnly CSI > c (DA2) is implemented, not CSI > 0 q (XTVERSION)
Zellij✓v0.31.0Returns 'Zellij(version)' in response to CSI > 0 q - implemented in sixel support PR

See also​