OSC = Operating System Command, a family of terminal control sequences that lets programs change terminal emulator state.
In terminal, terminal emulator, xterm, and VT control sequence contexts, OSC means Operating System Command.
It is not a normal command typed into a shell. It is a special byte sequence written to the terminal output stream. The terminal emulator interprets it as an instruction for terminal state instead of rendering it as ordinary text.
For example, command-line programs can use OSC to set the window title, emit clickable terminal hyperlinks, query or change colors, write to the clipboard, or tell the terminal the current working directory.
The common 7-bit form is:
ESC ] command ; data BEL
Where:
ESC is the escape character, hexadecimal 0x1b, often written as \033, \x1b, or \e in shell examples.] starts an OSC sequence.BEL terminates the sequence, hexadecimal 0x07, often written as \a.ST, written as ESC \, can also terminate the sequence.Example: set a terminal title.
printf '\033]0;Demo Title\a'
A supporting terminal will not print ]0;Demo Title. It will set the window title to Demo Title.
| Concept | Typical Form | Interpreted By | Purpose |
|---|---|---|---|
| Shell command | ls, cd, git status | The shell or an executable program | Run programs, read files, write files, start processes |
| CSI sequence | ESC [ 31m | The terminal emulator | Move the cursor, set text color, clear the screen |
| OSC sequence | ESC ] 0 ; title BEL | The terminal emulator | Set titles, color tables, hyperlinks, clipboards, and other string-oriented terminal state |
As a rough rule: CSI is common for display control inside the screen, such as color, cursor movement, and clearing; OSC is common for terminal emulator state and extensions, such as titles, palettes, clipboards, and hyperlinks.
printf '\033]0;project: api-server\a'
printf '\033]2;project: api-server\a'
Shell prompts, SSH helpers, and terminal integrations often use these to show the current host, directory, or task.
# Exact support depends on the terminal emulator.
printf '\033]4;1;rgb:ff/00/00\a'
This family of sequences is used for terminal color table operations. Support differs across terminals.
printf '\033]8;;https://example.com\aExample\033]8;;\a'
Terminals that support OSC 8 display Example as a clickable link.
# SGVsbG8= is Base64 for "Hello".
printf '\033]52;c;SGVsbG8=\a'
OSC 52 can write content to the clipboard. Because it affects user clipboard state, many terminals disable it, limit it, or require explicit user configuration.
OSC means that terminal output can trigger terminal behavior. Untrusted text printed directly to a terminal may do more than display characters.
cat on unknown binary files, logs, or escape sequence samples.ESC and C1 controls.OSC is the terminal control sequence family for string-oriented terminal commands: a program writes ESC ] ... BEL, and the terminal emulator may use it to set titles, links, colors, clipboards, and related state.