Skip to main content
ansicode

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\a
ESC [ESC ] 0 ; TITLE BEL
hex1b 5d 30 3b ... 07

Description

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

bash
printf '\033]0;Hello window\007'
python
import sys; sys.stdout.write('\x1b]0;Hello window\x07')
go
fmt.Print("\x1b]0;Hello window\x07")
javascript
process.stdout.write('\x1b]0;Hello window\x07')
c
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

Related sequences

In the family cookbook

OSC cookbook · 1. The envelope — `\x1b]` … `\x07` or `\x1b\\`