wire / terminal-osc / 7

OSC 7 — Report current working directory (file:// URL)

OSC 7 ; file://host/path ST tells the terminal the shell's current working directory as a file URL. Terminals use it to open new tabs/splits in the same directory and to resolve relative paths in hyperlinks. Emitted by the shell from a precmd/PROMPT_COMMAND hook. Originated with iTerm2; now broadly supported.

terminal-osc kind control-sequence status de-facto verification verified tier C terminal-escape@1

aka: report cwd · current working directory · OSC 7 · ESC ] 7 · cwd reporting

frame

OSC introducer: \x1b] ESC ] (0x1B 0x5D)

terminator (ST|BEL): ST \x1b\ · BEL \x07

parameters / subcommands

idnamebytes (ST)meaning
set Report cwd \x1b]7;file://myhost/home/user/project\x1b\ OSC 7 ; file://HOST/PATH ST reports the shell's current working directory. HOST is the hostname (so the terminal can tell local vs remote/ssh) and PATH is the absolute, percent-encoded path. The shell emits this from precmd / PROMPT_COMMAND after each directory change.

support matrix

terminallevelsincenotes
iTerm2fulldocumentedOrigin of OSC 7 cwd reporting; opens new sessions in the reported directory.
VTE / GNOME TerminalfullVTE 0.38+Uses the file:// URI to spawn new terminals in the same directory.
WezTermfulldocumentedReads OSC 7 to spawn tabs/panes in the current directory.
kittyfulldocumentedHonors OSC 7 for new-window cwd inheritance.
Windows TerminalfulldocumentedUses OSC 7 to duplicate tabs in the same working directory.

gotchas


provenance

per-fact attribution:

see also

agent: curl -H 'accept: application/json' wire.phall.io/terminal-osc/7 or /terminal-osc/7.json