OSC 2
OSC 2 sets the window title of the terminal without modifying the icon name. In practice, most modern terminals treat this identically to OSC 0 since the icon name distinction is largely obsolete.
Syntax
OSC 2 ; Pt BEL
OSC 2 ; Pt ST
OSC2 = 0x1b, "]", "2", ";", text, ( 0x07 | 0x1b, "\\" ) ;
text = character, { character } ;Parameters
| Parameter | Description | Default |
|---|---|---|
Pt | The text string to use as the window title | (none) |
Description
Per the XTerm control sequences documentation, OSC 2 changes the window title to the string Pt. Unlike OSC 0, it does not affect the icon name (the label shown when the window is iconified in X11).
In modern terminal emulators, the distinction between icon name and window title is mostly irrelevant. The icon name was meaningful in classic X11 window managers where minimized windows displayed a small icon with a text label. Today, most desktop environments do not expose separate icon names, making OSC 2 and OSC 0 functionally equivalent in nearly all cases.
The text parameter Pt is terminated by either BEL (0x07) or ST (String Terminator, ESC ).
Examples
# Set window title to "Editor"
printf '\e]2;Editor\a'
# Set window title using ST terminator
printf '\e]2;Editor\e\\'
# Display hostname in title bar
printf '\e]2;%s@%s\a' "$USER" "$HOSTNAME"
Specifications
| Specification | Section |
|---|---|
| XTerm ctlseqs | — |
Terminal support
| Terminal | Support | Version | Notes |
|---|---|---|---|
| Terminal Emulators | |||
| Alacritty | ✓ | Yes | Listed as IMPLEMENTED in escape_support.md:97 |
| Bobcat | ✓ | 0.9.0 | WhenTitle callback set up from initial release |
| contour | ✓ | v0.1.0 | |
| foot | ✓ | Yes | Sets window title, osc.c:1306-1308 |
| Ghostty | ✓ | v1.0.0 | |
| iTerm2 | ✓ | v20260216-nightly | |
| Kitty | ✓ | Yes | |
| Konsole | ✓ | Yes | WindowTitle enum value 2 in src/session/Session.h:414 |
| mintty | ✓ | Yes | Implemented at termout.c:4686, sets window title |
| mlterm | ✓ | rel-2_9_1 | |
| PuTTY | ✓ | Yes | Sets window title (terminal.c:3215-3224) |
| Rio | ✓ | v0.0.28 | |
| rxvt-unicode | ✓ | rxvt-unicode-2.0 | |
| st | ✓ | 0.4 | |
| terminology | ✓ | v0.1.0 | |
| VT100 | ✗ | No | |
| VTE | ✓ | Yes | OSC 2 (XTERM_SET_WINDOW_TITLE) handled in vteseq.cc |
| WezTerm | ✓ | Yes | OSC 2 SetWindowTitle - see wezterm-escape-parser/src/osc.rs:35,307,460 |
| Windows Terminal | ✓ | Yes | SetWindowTitle case in ActionOscDispatch |
| xterm | ✓ | Yes | OSC 2 sets window title only (OSC_TitleOnly in misc.c:3482) |
| xterm.js | ✓ | 0.3 | |
| Multiplexers | |||
| cy | ✓ | Yes | |
| GNU Screen | ✓ | v.4.2.0 | |
| tmux | ✓ | 0.8 | Requires allow-set-title option |
| tuios | ✓ | v0.0.15 | |
| Zellij | ✓ | v0.12.0 | |
See also
- OSC 0 — Set Icon Name and Window Title — Sets both icon name and window title simultaneously