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
AlacrittyNo
Bobcat0.9.0SetDeviceId() sets terminal name/version response. Added in commit 0eac0f8 (2025-01-15) for 'Extended device attributes (CSI q <) response'.
contourv0.1.0XTVERSION (CSI > 0 q) implemented in Functions.h line 618 and Screen.cpp line 3947-3949, returns terminal name and version
foot1.7.0Replies with DCS>|foot(major.minor.patch)ST
Ghosttyv1.0.0CSI > q
iTerm2YesCSI > 0 q terminal version query supported
Kitty0.21.2
KonsoleYesResponds to CSI > q with terminal identification
minttyYesXTVERSION (CSI > q) implemented at src/termout.c:3144-3146
mlterm3.9.2Responds with 'DCS>|mlterm(version)ST'
PuTTYNo
Riov0.2.33
rxvt-unicode1.2Via CSI > c (secondary DA) - reports 'U' for urxvt with version info
stNo
terminologyv0.1.0Reports as VT420 with version 337
VT100No
VTENoMentioned in terminfo but no handler found in code
WezTermYesTerminal version response supported
Windows TerminalNo
xtermxterm-230CSI > 0 q - Report xterm name and version (XTVERSION)
xterm.jsYesIn master, not yet released
Multiplexers
cyNo
GNU ScreenNoOnly DA1 (CSI c) is supported, not DA2 (CSI > c)
tmux3.2Responds to CSI > q primary device attributes
tuiosNoOnly CSI > c (DA2) is implemented, not CSI > 0 q (XTVERSION)
Zellijv0.31.0Returns 'Zellij(version)' in response to CSI > 0 q - implemented in sixel support PR

See also