OSC 9 Desktop Notification
Ask the terminal to show a desktop notification.
OSC 9 ; Pt ST
- ECMA-48
- §8.3.89 OSC – Operating System Command, p. 51
- Specification
- Post a notification, iTerm2 documentation
OSC 9 ; Pt ST asks the terminal to show Pt in a notification on the desktop, for instance when a long build finishes. It is iTerm2’s, in its escape code documentation. A notification with a title as well is OSC 777 ; notify ; title ; body ST, and kitty has its own, richer OSC 99.
OSC 9 is also used by ConEmu, on Windows, for its own commands, each a number after the 9, the best known of which is the progress report, OSC 9 ; 4. A terminal that has both tells them apart by what follows the 9: one of ConEmu’s numbers and a ;, or text.
It is not xterm’s, and a default xterm ignores it (the OSC numbers it knows). The cases follow xterm.
libghostty-vt passes it to its host through the DESKTOP_NOTIFICATION callback, which the runner does not install. What a case can see is that it prints nothing, answers nothing and does not ring the bell, and libghostty-vt passes.
Support
| Terminal | Version | Support | Notes |
|---|---|---|---|
| VT220 | manual, 2nd ed., 1984 | No | OSC is not among the controls it recognizes (§4.2) |
| VT510 | manual, 1st ed., 1993 | No | ignores an OSC string (chapter 4) |
| xterm | patch 412, xterm-411a | No | ignored |
| libghostty-vt | 0f171f6 | Yes | passed to the host’s DESKTOP_NOTIFICATION callback |
| Konsole | 26.11.70, a24c3d71 | No | its OSC 9 handling acts only on ConEmu’s 9 ; 4 |
| iTerm2 | 3.7.3, its documentation | Yes | Proprietary Escape Codes |
| ConEmu | build 230724, its documentation | No | its OSC 9 is followed by a command number; no notification in its ANSI escape codes |
Validation
OSC9-1: A notification changes nothing on screen
A
\e]9;Build finished\a
B
|AB____|
cursor 1,3
reply none
bell 0