OSC 1337 iTerm2 Extensions
iTerm2's own commands: inline images, marks, user variables, the clipboard and the working directory, and its other OSC extensions.
OSC 1337 ; Pt ST
- ECMA-48
- §8.3.89 OSC – Operating System Command, p. 51
- Specification
- Proprietary Escape Codes, iTerm2 documentation
iTerm2, the macOS terminal, puts most of its own commands under one OSC number, 1337, as OSC 1337 ; Key=value ST; it used OSC 50 once, and moved because xterm uses 50 for fonts. Their definition is iTerm2’s Proprietary Escape Codes page and the pages it links to:
Pt | Does | libghostty-vt |
|---|---|---|
AddAnnotation=message | attach a note to the text at the cursor, and show it | ignored |
AddHiddenAnnotation=message | attach a note without showing it | ignored |
Block=id=name;attr=start | mark where a block of text starts, or with attr=end ends, for folding and copy buttons | ignored |
Button=type=copy;block=name | add a button that copies a block; type=custom adds one that sends a code back | ignored |
Capabilities | ask which features the terminal has; answered OSC 1337 ; Capabilities=features ST, from iTerm2’s feature reporting protocol | not recognized; ignored, so not answered |
ClearCapturedOutput | erase the output captured from the last command | ignored |
ClearScrollback | erase the scrollback | ignored |
Copy=:base64 | put text on the clipboard | passed to the host, as OSC 52 |
CopyToClipboard=name | copy all the text that follows to a clipboard, until EndCopy | ignored |
CurrentDir=dir | report the shell’s working directory | kept, as OSC 7 |
CursorShape=n | 0 block, 1 bar, 2 underline, from Konsole | ignored |
Custom=id=secret:pattern | a sequence a script defines itself | ignored |
Disinter | bring back a session that was buried | ignored |
EndCopy | end CopyToClipboard | ignored |
File=args:base64 | show a file, usually an image, inline in the text, or download it | ignored |
FileEnd | end a file sent with MultipartFile | ignored |
FilePart=base64 | one piece of a file sent with MultipartFile | ignored |
HighlightCursorLine=yes | show or hide the cursor guide, a highlight on the cursor’s line | ignored |
MultipartFile=args | start a file sent in pieces, as File does at once, for tmux | ignored |
OpenURL=:base64 | ask to open a URL, with the user’s permission | ignored |
PopKeyLabels | restore the Touch Bar’s labels from the stack | ignored |
PushKeyLabels | save the Touch Bar’s labels on a stack | ignored |
RemoteHost=user@host | report the user and host the shell is on | ignored |
ReportCellSize | ask for a cell’s size in points; answered OSC 1337 ; ReportCellSize=h;w;scale ST | not answered |
ReportVariable=base64 | ask for one of iTerm2’s variables | not answered |
RequestAttention=yes | bounce the dock icon; once, no, or fireworks at the cursor | ignored |
RequestUpload=format=tgz | ask the user for files to upload | ignored |
SetBackgroundImageFile=base64 | show a picture behind the text, with the user’s permission | ignored |
SetBadgeFormat=base64 | set the badge, text drawn in the corner of the session | ignored |
SetColors=key=value | change one of the session’s colors | ignored |
SetKeyLabel=key=value | label a Touch Bar key | ignored |
SetMark | set a mark to jump back to | ignored |
SetProfile=name | change the session’s profile | ignored |
SetProfileProperty=key=base64 | change one setting of the session’s profile, given as JSON | not recognized; ignored |
SetUserVar=name=base64 | set a variable iTerm2 can show, such as in a tab title | ignored |
ShellIntegrationVersion=n | report the version of iTerm2’s shell integration | ignored |
StealFocus | bring the window forward | ignored |
UnicodeVersion=n | choose Unicode 8’s or 9’s character widths | ignored |
UpdateBlock=id=name;action=fold | fold or unfold a block | not recognized; ignored |
That is every key iTerm2 documents, in its Proprietary Escape Codes page and in the pages it sends a reader to for images, badges and feature reporting. libghostty-vt recognizes all but three, without regard to case, and acts on two, Copy and CurrentDir; it consumes the rest without doing anything. The three it does not know, Capabilities, SetProfileProperty and UpdateBlock, are newer, and it ignores them all the same.
iTerm2 has a few extensions outside 1337 as well:
| Sequence | Does | libghostty-vt |
|---|---|---|
OSC 4 ; -1 ; ? ST, OSC 4 ; -2 ; ? ST | ask for the default foreground and background, through the palette query | not answered |
OSC 6 ; 1 ; bg ; red ; brightness ; n ST | color the tab; the same for green and blue; see OSC 6 | ignored |
OSC 21337 | set the tab’s status text and indicator | ignored |
OSC P | change a color, the Linux console’s way | ignored |
and it documents others that this site gives pages of their own: notifications with OSC 9, progress with OSC 9 ; 4, FinalTerm’s shell integration marks with OSC 133, hyperlinks, and its answer to XTVERSION, iTerm2 and its version.
A default xterm has none of these and ignores them (the OSC numbers it knows). OSC 6 is xterm’s own, for turning its special colors on and off, but iTerm2’s string does not parse as that and changes nothing (do_osc); OSC 4 ; -1 is a negative color number, where xterm stops (ChangeAnsiColorRequest). The cases follow xterm, so the one where libghostty-vt keeps the working directory is a known difference.
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 | Partly | acts on Copy and CurrentDir and consumes the rest (ITERM2-1) |
| Konsole | 26.11.70, a24c3d71 | Partly | only inline images (File, MultipartFile) and ReportCellSize |
| iTerm2 | 3.7.3, its documentation | Yes | Proprietary Escape Codes |
| ConEmu | build 230724, its documentation | No | not in its ANSI escape codes |
Validation
ITERM2-1: The working directory
\e]1337;CurrentDir=/home/user\a
|______|
pwd ""
ITERM2-2: The clipboard changes nothing on screen
A
\e]1337;Copy=:SGVsbG8=\a # "Hello"
B
|AB____|
cursor 1,3
reply none
ITERM2-3: The rest are consumed
A
\e]1337;SetMark\a
\e]1337;SetUserVar=name=dmFsdWU=\a
\e]1337;RemoteHost=user@example.com\a
\e]1337;CursorShape=1\a
\e]1337;File=inline=1:SGVsbG8=\a
B
|AB____|
cursor 1,3
reply none
ITERM2-4: Questions are not answered
\e]1337;ReportCellSize\a
\e]1337;ReportVariable=c2Vzc2lvbi5uYW1l\a
\e]4;-1;?\a
|______|
reply none
ITERM2-5: Tab colors
A
\e]6;1;bg;red;brightness;255\a
B
|AB____|
cursor 1,3
ITERM2-6: Newer keys are ignored too
A
\e]1337;Capabilities\a
\e]1337;SetProfileProperty=Cursor Type=Mg==\a
\e]1337;UpdateBlock=id=b;action=fold\a
B
|AB____|
cursor 1,3
reply none