Skip to main content
ansicode

OSC 9 — Toast notification (iTerm2 / Windows Terminal)

Trigger a native OS desktop notification from the terminal — long-running job done, build finished, etc.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b]9;MESSAGE\x07
\\033[\033]9;MESSAGE\007
\\e[\e]9;MESSAGE\a
ESC [ESC ] 9 ; MESSAGE BEL
hex1b 5d 39 3b ... 07

Description

Raise a system-tray / Notification Center / KNotifications toast with the given message string. Originally iTerm2's `iTerm2 growl` mechanism (the OSC 9 alias dates to the Growl daemon era on macOS); Windows Terminal adopted the same control later. The terminal forwards the payload to the host OS notification API — the user sees a banner outside the terminal window, useful for long compiles, `make && say done` substitutes, CI pollers. Unsupported terminals drop the entire OSC 9 frame silently, so it is safe to emit unconditionally. Caveat: ConEmu repurposes OSC 9 as its progress-bar protocol (`\x1b]9;4;<state>;<percent>\x07`) — a different scheme — so check your terminal docs before sending complex OSC 9 payloads.

Spec citation: iTerm2 Proprietary Escape Codes (OSC 9) / Windows Terminal

Examples

bash
make && printf '\033]9;build finished\007'
python
import sys; sys.stdout.write('\x1b]9;build finished\x07')
go
fmt.Print("\x1b]9;build finished\x07")
javascript
process.stdout.write('\x1b]9;build finished\x07')
c
printf("\x1b]9;build finished\x07");

Terminal support

xterm
no
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
no
kitty
no
alacritty
no
WezTerm
yes
Ghostty
yes
GNOME Terminal
no
Konsole
partial
tmux
no
GNU screen
no

Related sequences

In the family cookbook

OSC cookbook · 6. Inline images & progress — `OSC 1337` and `OSC 9 ; 4`