[FEATURE] OSC 8 Hyperlinks for Clickable File Paths
Problem Statement
When Claude Code outputs file paths like /Users/user/project/src/foo.ts:42, they are not clickable in terminals that support hyperlinks (Kitty, iTerm2, WezTerm, Windows Terminal).
This happens because:
- Paths are output as plain text without the
file://scheme - ANSI color codes wrapped around paths break terminal pattern matching
- The
path:lineformat isn't recognized as a clickable URL
Users must manually copy paths or use terminal-specific workarounds (like Kitty's hints kitten) to navigate to files.
Proposed Solution
Emit file paths using the OSC 8 hyperlink escape sequence, which is the terminal standard for embedded hyperlinks:
\033]8;;file:///absolute/path/to/file.ts\033\\file.ts:42\033]8;;\033\\
This makes paths clickable with a single click (or Cmd/Ctrl+click depending on terminal config). Many modern CLI tools already do this (ls, exa/eza, fd, bat).
Reference: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
Alternative Solutions
- Workaround I currently use: Kitty's hints kitten (
Cmd+Shift+Fto select paths) - works but requires extra keystrokes - file:// prefix only: Would partially help but less robust than OSC 8
- Opt-in config: Could be a setting if terminal compatibility is a concern
Use Case Example
- I ask Claude Code to find a bug in my project
- Claude outputs: "The issue is in
/Users/victor/project/src/auth.ts:142" - Currently: I manually copy the path or use hints kitten
- With this feature: I Cmd+click the path and it opens in my editor
This is especially valuable when Claude references multiple files in a single response.
Additional Context
OSC 8 terminal support (https://github.com/Alhadis/OSC8-Adoption):
- Kitty, iTerm2 (3.1+), WezTerm, Windows Terminal
- GNOME Terminal (VTE 0.50+), foot, Konsole
- Alacritty (recent versions)
Related but distinct from #609 (URL text wrapping) - this is about file paths not being hyperlinks at all.
Environment: macOS, Kitty terminal with detect_urls yes, allow_hyperlinks yes
22 Comments
This is critical
It's not clear what is selected
<img width="1143" height="279" alt="Image" src="https://github.com/user-attachments/assets/7d0c92dc-4ab0-4339-b831-fc985297d120" />
Yep, this is my big issue with it too. Massive problem when you can't see what's selected and makes referencing files, which we do all the time, really cumbersome to use.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Here's a solution for the visitors.
I personally use Ghostty and wanted the links in Claude Code to become clickable.
https://github.com/mash/osc8wrap
@mash Clickable links in that form as you demonstrated are not a challenge. Custom links were you see not the url but its label (like HTML
<a href="URL">LABEL</a>) is. It's very useful think in terminal and i use it heavily. I already do have custom status linke but I'd cram more info there if some of my links could be OSC 8 links (with short label and url not exposed directly).i.e. try to run this directly in compatible terminal
and then try to return this from statusline - will not work.
it would be great if file paths are clickable as well. when the text claude outputs has file links it, should also be compatable with osc 8. this will help a lot to review or follow the file
I ran into an issue with OSC 8 hyperlinks where the sequence did not work in the Claude Code statusline, and I was able to narrow it down to the choice of terminator.
What didn’t work (ST / ESC \)
What works (BEL / 0x07)
Technical notes
OSC 8 sequences support two possible terminators:
|Terminator | Escape sequence | Compatibility|
| ---- | ---- | ---- |
| ST (String Terminator) | \x1b\\ (ESC \) | Not reliably handled in some environments |
| BEL | \x07 | Historically supported, more widely compatible |
In the Claude Code statusline rendering path, the ST terminator does not appear to be interpreted correctly. Switching to BEL makes the hyperlink work as expected.
Since many terminal emulators have long supported BEL as an OSC terminator, using BEL by default (or at least providing it as a fallback) may provide better compatibility, especially in statusline or intermediate rendering contexts (e.g. tmux-like pipelines).
Verified in practice
I have confirmed that this works correctly in a real statusline implementation:
https://github.com/him0/claude-code-statusline
Just tested and seems
BELis working workaround to make custom links work with status line. Thanks @him0Use Case: Paths with Spaces
Adding voice to this request with a specific use case: file paths containing spaces.
Current Behavior
When Claude Code outputs a path like:
The path breaks at the space — terminal treats
Project/docs/file.mdas a separate token. Not clickable.Workaround (Ugly)
Current workaround via CLAUDE.md instructions:
Works, but the
%20encoding is visually noisy and harder to read.Desired Behavior
Other CLI tools (e.g., Codex) output paths with OSC 8 hyperlinks:
/Users/name/Projects/My Project/docs/file.md(clean, underlined, clickable)file:///Users/name/Projects/My%20Project/docs/file.mdWhy This Matters
macOS conventions use Title Case with spaces for folders (
Documentation,Source Code, project names). These are common in real-world projects. OSC 8 would let Claude Code display human-readable paths while maintaining clickability.Terminal Support
Both iTerm2 and Ghostty fully support OSC 8 hyperlinks.
---
Co-Authored-By: Claude Code <noreply@anthropic.com>
This issue is a real pain point for me too.
I’ve been using a workaround that’s been stable in daily use:
• a strict CLAUDE.md rule to output OSC-8 links for file/web references
• short visible labels
• plain absolute-path fallback line for local files
• BEL-terminated OSC-8 output for compatibility-sensitive paths
• explicit Bash printf OSC-8 emit patterns in the instructions so output is consistent
sample image of how it looks (all urls and paths are cmd-clickable):
<img width="235" height="228" alt="Image" src="https://github.com/user-attachments/assets/3c5934ce-2ba6-4a64-b466-e0a2f4f50c90" />
Exact CLAUDE.md workaround block (copy/paste): https://gist.github.com/gradigit/b7f924aed6fe7ea042ebe3811cad777f
---
I also built a helper tool (https://github.com/gradigit/claude-pager). I use ctrl-g to edit prompts very often anyway, and along with actually being able to see the session context, it also shortens links and makes them highlighted and clickabled. It made this workflow much more usable.
Before:
<img width="400" height="300" alt="Image" src="https://github.com/user-attachments/assets/d8b0ae35-4f48-427d-b99b-4ec744234272" />
After:
<img width="400" height="300" alt="Image" src="https://github.com/user-attachments/assets/af830bc4-7447-4869-8dd7-5be26b912f71" />
This is still a workaround, not a replacement for native support.
I’d love to see first-class OSC-8 behavior in Claude Code across all rendering paths.
+1 — tried to get ahead of this by implementing OSC 8
file://hyperlinks in a custom statusline (for clickable working directory + clickable modified-file basenames on a second statusline row). The escape sequences generate correctly but don't render as clickable in standalone terminals due to #26356.Beyond the statusline, having native OSC 8 wrapping on file paths in Claude's own responses would be a huge UX win. Right now we get colored
path:linetext that you have to manually copy. With OSC 8, you'd Ctrl+click straight into your editor. Tools likeeza,fd, andbatalready do this — Claude Code output should too.Yeah, this should be a no-brainer?
Have a post-processing step looking for path-like strings (including line:col). Then checking which paths leads to real files/dirs and linkify them in the output (kinda optional, but perhaps nice). Ideally the link format would be configurable as well. I want to output
zed:///file/...:$LINE:$COL<details>
<summary>Workaround: The Kitty terminal has a feature which linkify all path-looking strings
</summary>
https://sw.kovidgoyal.net/kitty/conf/#shortcut-kitty.Insert-selected-path
It's primary purpose is to easily grab the text and insert, but it also linkify the text so you can click them. The program handling the click is configurable:
It works with line numbered paths as well.
</details>
Huh, it's is precisely the challenge. Sure it might be EVEN nicer if the path where intelligently shortened (in such a way that it was self evident for the user which file the shorted link referred to) . But this is a much harder problem and would likely need to be done by the model (or a post-processing mode) burning token better spent on other thing IMO. (unless I misread you?)
I think it's awesome that someone made
osc8wrap- a pty proxy which linkify terminal output (in theory from arbitrary programs) if I understand correctly? I'm curious how well it works in practice though. Before I landed on using the built-in Kitty functionality I brainstormed a similar tool with Claude and got scared by the hairiness of the problem.Though - in the few cases where the Claude harness output information such links should be used. The edit tool already linkify the path inside
* Update(...). But it could also linkfy the linenumber in the diff (this would require to redo how the numbering is done somewhat) If not - at least provide a line-numbered path for the beginning of the hunks shown.https://github.com/anthropics/claude-code/issues/13008#issuecomment-3968687969
the shortening is part of why i built claude-pager, so i can press ctrl+g and quickly get a shortened link that still makes sense.
im working on trying to display the diff view next, and i think your linenumber in diff idea might be worth implementing into claude-pager as well.
I'll see if that's possible
Still an issue.
Will give https://github.com/mash/osc8wrap a try in the interim.
Definitely an issue for AWS console links as well. I'm having Claude do an AWS deploy, launch some process, and then give me a link to the AWS console page for it.
The AWS console links are notoriously long, and end up wrapping within my Claude terminal width. The indentation from the TUI breaks the link detection in iterm and only the first line becomes clickable
OSC8 would be a natural fix for this issue 🙏
<img width="358" height="435" alt="Image" src="https://github.com/user-attachments/assets/9bf61692-e42c-4dea-9c96-6c77b5aa7492" />
Until Claude Code supports OSC 8 hyperlinks natively, here are ways to make file paths clickable:
Workaround 1 — Terminal-specific path detection:
Most modern terminals can auto-detect file paths if configured:
(/[^:]+):(\d+)kitty.conf):``
``map ctrl+shift+o kitten hints --type path --program "code --goto {}"
wezterm.lua):``
lua
``config.hyperlink_rules = {
-- Match file:line patterns
{ regex = '([/~][\\w./-]+\\.\\w+):(\\d+)', format = 'file://$1#$2' },
}
Workaround 2 — Use VS Code extension:
The VS Code extension renders file paths as clickable links in the Native UI. Clicking opens the file at the correct line. This is the easiest solution if you're using VS Code.
Workaround 3 — PostToolUse hook to create clickable links:
This is experimental, but you could post-process output:
Workaround 4 — tmux + vim keybinding:
In tmux, you can select paths and open them:
Press
Ctrl+B oto open the last file path in your editor.Worth noting: Claude Code itself reports that OSC8 links are not currently supported when asked. It would be a nice touch if the feature detection and rendering were consistent - i.e., Claude Code renders OSC8 links when the parent terminal supports them, rather than telling users it can't.
While waiting for native OSC 8 support in Claude Code, I built a cross-platform workaround: termlink
It's a PTY proxy (Node.js + node-pty) that sits between Claude Code and your terminal, detects file paths in the output stream, and wraps them with OSC 8 hyperlinks. Ctrl+Click to open files.
Key features
path:line:colformats (100+ file extensions)file://URIs → opens with system default applicationtermlink --setupconfigures your shell (PowerShell/bash/zsh)Install & use
Repo: https://github.com/dopawei/termlink
Tested on Windows Terminal + Claude Code. Should also work on iTerm2, Kitty, WezTerm, and any OSC 8-capable terminal.
Would love to see this built natively into Claude Code, but hope this helps others in the meantime!
Root cause found: outdated
supports-hyperlinksdependencyAfter digging into Claude Code v2.1.88's bundled source, I found the exact reason file paths aren't clickable on Windows:
Claude Code already has full OSC 8 hyperlink infrastructure —
ink-linkcomponent,pathToFileURL(), the\x1B]8;;escape sequences — it's all there and working.But the bundled
supports-hyperlinkspackage has this detection logic:Meanwhile, the latest
supports-hyperlinksv4.4.0 already fixed this:The fix is simply updating the
supports-hyperlinksdependency. Windows Terminal has supported OSC 8 since v1.4 (2020), and the latestsupports-hyperlinkscorrectly detects it via theWT_SESSIONenvironment variable.As a temporary workaround, users can set
FORCE_HYPERLINK=1— the detection code respects this env var and skips all platform checks. But updating the dependency is the proper fix.TL;DR: The rendering pipeline works. The detection is outdated. Update
supports-hyperlinks→ Windows users get clickable file paths for free.This is still broken in the new TUI fullscreen interface.
+1 — running Claude Code in a plain Linux terminal (no IDE integration), and file paths it prints are dead text. When Claude creates or references a file (e.g. a drafted letter/report .md), I want to Ctrl+click it open right from the terminal.
Concretely:
file://URI (most modern terminals — GNOME Terminal, Konsole, kitty, WezTerm — make these clickable out of the box).file://OSC 8 / markdown), e.g. a setting liketerminalLinkFormat, since capability varies by terminal and some users want emission off entirely (#72998).Today the only workaround is asking the model to print
file://URIs manually, which it doesn't do by default and doesn't persist.