Skip to main content

OSC 2

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

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
Formal syntax
OSC2 = 0x1b, "]", "2", ";", text, ( 0x07 | 0x1b, "\\" ) ;
text = character, { character } ;

Parameters​

ParameterDescriptionDefault
PtThe 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​

SpecificationSection
XTerm ctlseqs—

Terminal support​

TerminalSupportVersionNotes
Terminal Emulators
Alacritty✓YesListed as IMPLEMENTED in escape_support.md:97
Bobcat✓0.9.0WhenTitle callback set up from initial release
contour✓v0.1.0
foot✓YesSets window title, osc.c:1306-1308
Ghostty✓v1.0.0
iTerm2✓v20260216-nightly
Kitty✓Yes
Konsole✓YesWindowTitle enum value 2 in src/session/Session.h:414
mintty✓YesImplemented at termout.c:4686, sets window title
mlterm✓rel-2_9_1
PuTTY✓YesSets 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✓YesOSC 2 (XTERM_SET_WINDOW_TITLE) handled in vteseq.cc
WezTerm✓YesOSC 2 SetWindowTitle - see wezterm-escape-parser/src/osc.rs:35,307,460
Windows Terminal✓YesSetWindowTitle case in ActionOscDispatch
xterm✓YesOSC 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.8Requires allow-set-title option
tuios✓v0.0.15
Zellij✓v0.12.0

See also​