^[control-codes
live in libghostty-vt

Operating system commands

OSC 0 Set Icon Name and Window Title

View as Markdown

Set the window's title and its icon name to the same text.

OSC 0 ; Pt ST
ECMA-48
§8.3.89 OSC – Operating System Command, p. 51
xterm
Operating System Commands

OSC 0 ; Pt ST sets both the window’s title and its icon name, the name a window manager shows for it when it is iconified, to Pt. It is the one shells use most, since in a desktop with no icons the two come to the same thing. OSC 1 sets only the icon name, and OSC 2 only the title. The three came from dtterm, and xterm has had them since its beginnings.

Characters beyond Latin-1. xterm does not decode the UTF-8 of an OSC’s text: it collects it a byte at a time (doparsing, utf8_inparse). For OSC 0 and OSC 2 it keeps each byte whole when its utf8Title resource is on, which it is by default in a UTF-8 locale (set_utf8_feature), the one the cases assume. When the text becomes the title, xterm stores it as Latin-1 if it fits and as UTF-8 if it does not (ChangeGroup), so café ☕ comes through whole. What does not come through is a control character: the controls page has those. Its title modes, set with CSI > Ps t, let a program send the title in hexadecimal instead. libghostty-vt keeps the title as the UTF-8 it was sent, too.

As with OSC 2, xterm takes an empty OSC 0 as the title xterm.

libghostty-vt has no icon name: it keeps the title, which its host reads through the TITLE_CHANGED callback.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984NoOSC is not among the controls it recognizes (§4.2)
VT510manual, 1st ed., 1993Noignores an OSC string (chapter 4)
xtermpatch 412, xterm-411aYesin a UTF-8 locale the title keeps its UTF-8; controls become ?
libghostty-vt0f171f6Partlysets the title only, having no icon name
Konsole26.11.70, a24c3d71Yes
kitty0.49.1, run in a VMYespasses the 3 cases that show it working
foot1.28.0, run in a VMYespasses the 3 cases that show it working
pyte0.8.2, run as a libraryYespasses the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryYespasses the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryYespasses the 3 cases that show it working
ConEmubuild 230724, its documentationYesOSC 0..2 set the console window title, ANSI escape codes
rxvt-unicode9.31, run in a VMYespasses the 3 cases that show it working
VTE0.84.1, run as a libraryYespasses the 3 cases that show it working

Validation

OSC0-1: Sets the title

\e]0;Shell\a
|___|
title "Shell"

OSC0-2: Latin-1 is kept

\e]0;café\a
|___|
title "café"

OSC0-3: Beyond Latin-1

\e]0;café ☕\a
|___|
title "café ☕"

OSC0-4: Nothing on screen

A
\e]0;Shell\e\\
B
|AB_|
cursor 1,3
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.