Emit OSC 8 hyperlinks for displayed file paths (like URLs)
Feature request: emit OSC 8 hyperlinks for displayed file paths (like URLs)
Summary
Claude Code already emits OSC 8 terminal hyperlinks for URLs in its output, so in OSC-8-aware
terminals (Warp, iTerm2, Kitty, WezTerm, Ghostty) those URLs render as highlighted, clickable links.
But file paths shown in tool-result headers (Write(/path), Edit(...), Read(...)), diffs,
and prose are emitted as plain text — so they are neither highlighted nor clickable, even though
the terminal would happily make them so if they were OSC 8 links.
Please emit OSC 8 file:// hyperlinks for displayed file paths, the same way URLs are already
hyperlinked.
Why this is the right layer
Terminals cannot reliably auto-detect+highlight file paths the way they do URLs: URL detection is a
cheap regex, but confirming a path is a real file requires a filesystem check, which terminals won't
run on every frame. So they only linkify paths the emitter explicitly marks via OSC 8. Claude Code
is the emitter and knows exactly which strings are file paths — so a one-line OSC 8 wrap at the point
of display gives highlighting and click-to-open across every OSC-8 terminal, with zero
per-terminal work.
Proposed behavior
When printing a file path Claude Code already knows (tool headers, diffs, file_path fields), wrap
it in an OSC 8 hyperlink:
ESC ] 8 ; ; file:///absolute/path/to/file ST <displayed path text> ESC ] 8 ; ; ST
- Use the absolute path in the
file://URI (terminals resolvefile://directly). - For
path:line:column, either keep the display text as-is with a plainfile://URI, or encode
the line as file:///abs/path#L42 / ?line=42 if a target terminal/editor supports it (plain
file:// already delivers the core win).
- Gate behind a terminal-hyperlink-capability check if desired, or a setting
(e.g. terminalFileHyperlinks: true), defaulting on when the terminal advertises OSC 8 support.
Impact
- File paths become highlighted and clickable in every OSC-8 terminal, matching current URL
behavior — no terminal-side changes needed.
- Opening respects the terminal's own "open file links" editor setting.
Context
Verified against Warp: URLs in Claude Code output are OSC 8 and render highlighted/clickable; file
paths are plain text and do not. A terminal-side workaround (detect + validate paths at click time)
is possible but can't provide the persistent highlight without per-frame filesystem cost — which is
exactly why the emitter (Claude Code) is the correct place to mark them.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗