# Set Icon Name and Window Title (OSC 0)

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

- **Sequence:** `OSC 0 ; Pt ST`
- **ECMA-48:** [§8.3.89 OSC – Operating System Command, p. 51](https://archive.org/details/ecma-48-5th-edition-june-1991/page/n64/mode/1up)
- **xterm:** [Operating System Commands](https://invisible-island.net/xterm/ctlseqs/ctlseqs.html)

`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](https://control-codes.page/osc/icon/index.html.md) sets only the icon name, and
[OSC 2](https://control-codes.page/osc/title/index.html.md) 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`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L3384-L3456),
[`utf8_inparse`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L6489-L6490)). 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`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L10031-L10049)),
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`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/misc.c#L6181-L6235)), so `café ☕` comes through whole.
What does not come through is a control character: the
[controls](https://control-codes.page/parser/controls/index.html.md) 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](https://control-codes.page/osc/title/index.html.md), 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

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | No | OSC is not among the controls it recognizes ([§4.2](https://vt100.net/docs/vt220-rm/chapter4.html#S4.2)) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | No | ignores an OSC string ([chapter 4](https://vt100.net/docs/vt510-rm/chapter4.html)) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes | in a UTF-8 locale the title keeps its UTF-8; controls become `?` |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Partly | sets the title only, having no icon name |
| Konsole | 26.11.70, [a24c3d71](https://invent.kde.org/utilities/konsole/-/tree/a24c3d71be3684f24d030aa2dbe9bd723d985233) | Yes |  |
| kitty | 0.49.1, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/kitty.json) | Yes | passes the 3 cases that show it working |
| foot | 1.28.0, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/foot.json) | Yes | passes the 3 cases that show it working |
| pyte | 0.8.2, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/pyte.json) | Yes | passes the 3 cases that show it working |
| xterm.js headless | 6.0.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/xtermjs.json) | Yes | passes the 3 cases that show it working |
| alacritty_terminal | 0.26.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/alacritty.json) | Yes | passes the 3 cases that show it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | Yes | `OSC 0..2` set the console window title, [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |
| rxvt-unicode | 9.31, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/urxvt.json) | Yes | passes the 3 cases that show it working |
| VTE | 0.84.1, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/vte.json) | Yes | passes the 3 cases that show it working |

## Validation

### OSC0-1: Sets the title

Input, one step per line:

```text
\e]0;Shell\a
```

Expected screen:

```text
|___|
title "Shell"
```

### OSC0-2: Latin-1 is kept

Input, one step per line:

```text
\e]0;café\a
```

Expected screen:

```text
|___|
title "café"
```

### OSC0-3: Beyond Latin-1

Input, one step per line:

```text
\e]0;café ☕\a
```

Expected screen:

```text
|___|
title "café ☕"
```

### OSC0-4: Nothing on screen

Input, one step per line:

```text
A
\e]0;Shell\e\\
B
```

Expected screen:

```text
|AB_|
cursor 1,3
```

---

This is the Markdown version of <https://control-codes.page/osc/icon-and-title/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
