XTVERSION
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
(* 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:
| Terminal | Example response |
|---|---|
| XTerm | DCS > | XTerm(370) ST |
| foot | DCS > | foot(1.16.2) ST |
| Kitty | DCS > | kitty(0.26.5) ST |
| WezTerm | DCS > | WezTerm 20240203-110809-5046fc22 ST |
| tmux | DCS > | tmux 3.4 ST |
| Contour | DCS > | 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
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✗ | No | |
| Bobcat | ✓ | 0.9.0 | SetDeviceId() sets terminal name/version response. Added in commit 0eac0f8 (2025-01-15) for 'Extended device attributes (CSI q <) response'. |
| contour | ✓ | v0.1.0 | XTVERSION (CSI > 0 q) implemented in Functions.h line 618 and Screen.cpp line 3947-3949, returns terminal name and version |
| foot | ✓ | 1.7.0 | Replies with DCS>|foot(major.minor.patch)ST |
| Ghostty | ✓ | v1.0.0 | CSI > q |
| iTerm2 | ✓ | Yes | CSI > 0 q terminal version query supported |
| Kitty | ✓ | 0.21.2 | |
| Konsole | ✓ | Yes | Responds to CSI > q with terminal identification |
| mintty | ✓ | Yes | XTVERSION (CSI > q) implemented at src/termout.c:3144-3146 |
| mlterm | ✓ | 3.9.2 | Responds with 'DCS>|mlterm(version)ST' |
| PuTTY | ✗ | No | |
| Rio | ✓ | v0.2.33 | |
| rxvt-unicode | ✓ | 1.2 | Via CSI > c (secondary DA) - reports 'U' for urxvt with version info |
| st | ✗ | No | |
| terminology | ✓ | v0.1.0 | Reports as VT420 with version 337 |
| VT100 | ✗ | No | |
| VTE | ✗ | No | Mentioned in terminfo but no handler found in code |
| WezTerm | ✓ | Yes | Terminal version response supported |
| Windows Terminal | ✗ | No | |
| xterm | ✓ | xterm-230 | CSI > 0 q - Report xterm name and version (XTVERSION) |
| xterm.js | ✓ | Yes | In master, not yet released |
| Multiplexers | |||
| cy | ✗ | No | |
| GNU Screen | ✗ | No | Only DA1 (CSI c) is supported, not DA2 (CSI > c) |
| tmux | ✓ | 3.2 | Responds to CSI > q primary device attributes |
| tuios | ✗ | No | Only CSI > c (DA2) is implemented, not CSI > 0 q (XTVERSION) |
| Zellij | ✓ | v0.31.0 | Returns 'Zellij(version)' in response to CSI > 0 q - implemented in sixel support PR |
See also
- DA1 — Primary Device Attributes — VT-level feature query
- DA2 — Secondary Device Attributes — Numeric terminal identification
- DA3 — Tertiary Device Attributes — Terminal unit ID
- XTGETTCAP — Get Termcap/Terminfo — Query individual terminal capabilities