# 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.** A default xterm reads its input as UTF-8 and
collects the text of an OSC one character at a time. For `OSC 0` and
`OSC 2` it keeps characters up to U+00FF as they are, and turns every
character above that into `?`
([`doparsing`](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L3389-L3400),
[and the title text](https://github.com/ThomasDickey/xterm-snapshots/blob/xterm-411a/charproc.c#L3438-L3456)),
so `café` survives and an emoji or a CJK character does not. 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, every
character of it, which the case for that is a known difference.

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.

## 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, xterm writes ?

*A known difference: libghostty-vt does not pass this case.*

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>.
