OSC 0 / 2 — Set window/icon title
Change the terminal window's title bar text.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\\x1b[
\x1b]0;TITLE\x07\\033[
\033]0;TITLE\007\\e[
\e]0;TITLE\aESC [
ESC ] 0 ; TITLE BELhex
1b 5d 30 3b ... 07Description
OSC (Operating System Command) sequences start with `ESC ]` and end with either BEL (`\x07`, the de-facto xterm terminator) or ST (`ESC \`, `\x1b\\`, the standards-correct terminator). `OSC 0` sets both window and icon title, `OSC 1` only icon, `OSC 2` only window. Used by shells (PROMPT_COMMAND), tmux, screen, and tab-renaming tools. The terminator must always be present — a missing BEL/ST will hang the OSC parser until the next byte that happens to be one.
Spec citation: xterm-ctlseqs (OSC 0/1/2)
Examples
printf '\033]0;Hello window\007'import sys; sys.stdout.write('\x1b]0;Hello window\x07')fmt.Print("\x1b]0;Hello window\x07")process.stdout.write('\x1b]0;Hello window\x07')printf("\x1b]0;Hello window\x07");Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- yes
- iTerm2
- yes
- Windows Terminal
- yes
- cmd.exe / ConPTY
- yes
- kitty
- yes
- alacritty
- yes
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- yes
- Konsole
- yes
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | no | no |
Related sequences
In the family cookbook
OSC cookbook · 1. The envelope — `\x1b]` … `\x07` or `\x1b\\`