OSC 633 VS Code Shell Integration
VS Code's marks for prompts, commands and their output, with the command line and properties added to OSC 133's.
OSC 633 ; Ps [ ; Pt ] ST
- ECMA-48
- §8.3.89 OSC – Operating System Command, p. 51
- Specification
- Terminal shell integration, VS Code documentation
OSC 633 is the VS Code terminal’s version of OSC 133: marks a shell’s integration script sends so that the terminal knows where each prompt, command and output is. VS Code uses them to decorate commands with their status, to move between them, and to know the working directory.
Ps | Marks |
|---|---|
A | the start of a prompt |
B | the end of the prompt, where the command line starts |
C | just before the command’s output |
D [ ; exit-code ] | the end of the command; with no exit code, no command ran, as for an empty line or Ctrl+C |
E ; command-line [ ; nonce ] | the exact command line |
P ; Name=Value | a property: Cwd, IsWindows (True or False), or HasRichCommandDetection |
E exists because reading the command off the screen is unreliable. Its command line escapes \ as \\ and writes ;, and every character at or below space, as \xAB; the optional nonce, which VS Code gives the script, shows the sequence came from it, and some protections are relaxed when it matches. VS Code’s documentation asks other terminals to ignore these, and scripts to send them only when TERM_PROGRAM is vscode (shell integration). Its source knows further sub-commands that it marks as unfinished and not to be used (shellIntegrationAddon.ts).
A default xterm has no OSC 633 and ignores it (the OSC numbers it knows). The cases follow xterm.
libghostty-vt does not recognize OSC 633 either: its OSC parser in osc.zig has no state for the number, so the string is dropped, and the cases pass.
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 | 83edd49 | No | ignored |
| Konsole | 26.11.70, a24c3d71 | No | not among the OSC numbers it handles (Vt102Emulation.h) |
| ConEmu | build 230724, its documentation | No | not in its ANSI escape codes |
| VS Code | 1.140.0, its documentation | Yes | its own shell integration (documentation) |
Validation
OSC633-1: The marks do not show
\e]633;A\a$\s
\e]633;B\a
ls
\e]633;E;ls\a
\e]633;C\a
|$_ls__|
cursor 1,5
reply none
OSC633-2: Nor does a property, and the working directory is not set
A
\e]633;P;Cwd=/tmp\a
B
|AB____|
pwd ""
reply none