Title stack
Title Stack provides XTerm window manipulation sequences for pushing and popping window and icon titles on a stack, allowing applications to save and restore the terminal's title.
Syntax
CSI 22 ; Ps t Push title to stack
CSI 23 ; Ps t Pop title from stack
push_title = 0x1b, "[", "2", "2", ";", Ps, "t" ; pop_title = 0x1b, "[", "2", "3", ";", Ps, "t" ; Ps = "0" | "1" | "2" ;
Parameters
| Value | Description |
|---|---|
0 | Push or pop both the icon title and the window title |
1 | Push or pop the icon title only |
2 | Push or pop the window title only |
Description
These sequences manage a stack of window and icon titles, allowing applications to save the current title before changing it and restore the original title afterward. They are part of the XTerm CSI Ps ; Ps ; Ps t window manipulation family.
CSI 22 ; Ps t(Push) — Saves the current title(s) onto an internal stack. The title can then be changed freely using OSC 0 or OSC 2, knowing it can be restored later.CSI 23 ; Ps t(Pop) — Restores the most recently pushed title(s) from the stack and sets them as the current title(s). If the stack is empty, the operation has no effect.
The Ps parameter controls which titles are affected:
Ps | Push behavior | Pop behavior |
|---|---|---|
0 | Saves both the icon and window title | Restores both titles |
1 | Saves the icon title only | Restores the icon title only |
2 | Saves the window title only | Restores the window title only |
The title stack is particularly useful for applications that temporarily change the terminal title (for example, to display a filename or status) and need to restore the user's original title upon exit. Using the stack avoids the need for the application to query and store the original title itself.
The stack operates in a last-in, first-out (LIFO) manner. Multiple push operations can be performed before popping, and each pop restores the most recently pushed value.
Examples
# Save both titles, change title, then restore
printf '\e[22;0t' # Push current titles
printf '\e]2;My Application\a' # Set new window title
# ... application runs ...
printf '\e[23;0t' # Restore original titles
# Save only the window title
printf '\e[22;2t' # Push window title
printf '\e]2;Working...\a' # Set temporary title
printf '\e[23;2t' # Restore window title
Specifications
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Implemented via push_title()/pop_title() at term/mod.rs:2235,2249. Max stack depth: 4096 (TITLE_STACK_MAX_DEPTH) |
| Bobcat | ✓ | 0.9.0 | Handled by TerminalCtrl library |
| contour | ✓ | v0.1.0 | |
| foot | ~ | Yes | Implemented at csi.c:1392-1413, only handles title (param 0 or 2), ignores icon label (param 1) |
| Ghostty | ✓ | v1.0.0 | Only supports window title (params[1] = 0 or 2), not icon title |
| iTerm2 | ✓ | Yes | Both push (CSI 22 t) and pop (CSI 23 t) implemented with parameter support: 0=both, 1=icon, 2=window. See VT100Terminal.m:2793-2819 |
| Kitty | ✓ | Yes | Push/pop window title stack with maxlen=10 |
| Konsole | ✗ | No | Explicitly ignored with comment in code (src/Vt102Emulation.cpp:2014-2015) |
| mintty | ✓ | Yes | Full push/pop stack for window titles via CSI 22/23 t, implemented in src/termout.c:3059-3064 with stack management in src/winmain.c:1439-1464 |
| mlterm | ~ | 3.9.2 | When icon and window titles are pushed together (ps[1]=0), popping either one doesn't pop the other as xterm does. See XtermWinopsTests in esctest. |
| PuTTY | ✗ | No | Not implemented; no case 22 or 23 handlers in window manipulation code |
| Rio | ✓ | v0.0.28 | |
| rxvt-unicode | ✗ | No | Not implemented; no CSI 22/23 t handlers for push/pop title stack |
| st | ✗ | No | |
| terminology | ✓ | v1.7.0 | |
| VT100 | ✗ | No | |
| VTE | ~ | Yes | Only supports window title (CSI 22;0 t / CSI 22;2 t); icon title stack (CSI 22;1 t) not implemented. Max stack depth: 8 |
| WezTerm | ✗ | No | Parser recognizes sequences but handler is empty (no-op) at term/src/terminalstate/mod.rs:2090-2095 |
| Windows Terminal | ✗ | No | Not present in WindowManipulationType enum; only values 1,2,7,8,14,16,18 are supported |
| xterm | ✓ | xterm-406 | Requires OPT_TITLE_MODES compile flag (enabled by default) |
| xterm.js | ✓ | 4.4.0 | Requires windowOptions.pushTitle and windowOptions.popTitle to be enabled |
| Multiplexers | |||
| cy | ✗ | No | CSI t (XTWINOPS) explicitly ignored since v0.1.0 |
| GNU Screen | ✗ | No | CSI 22/23 t not implemented; no title stack functionality |
| tmux | ✓ | 2.7 | Supports both CSI 22 t (push) and CSI 23 t (pop) |
| tuios | ✗ | No | Only CSI 14/16/18 t are implemented in XTWINOPS handler |
| Zellij | ✓ | v0.16.0 | |
See also
- OSC 0 — Set Icon Name and Window Title — Set both icon and window title
- OSC 2 — Set Window Title — Set the window title
- Iconify — Minimize or restore the window