| Crates.io | add-osc-8-hyperlink |
| lib.rs | add-osc-8-hyperlink |
| version | 0.1.1 |
| created_at | 2025-12-04 12:31:15.245228+00 |
| updated_at | 2025-12-05 13:19:49.896089+00 |
| description | Add OSC 8 hyperlinks to file paths in terminal output |
| homepage | |
| repository | https://github.com/konradko/add-osc-8-hyperlink-rs |
| max_upload_size | |
| id | 1966432 |
| size | 12,538 |
A Rust port of sentriz/add-osc-8-hyperlink.
Add clickable OSC 8 hyperlinks to file paths in terminal output. Useful for commands that don't have native hyperlink support.
Some tools have built-in OSC 8 hyperlink support - use that instead:
rg --hyperlink-format='file://{host}{path}' (or add to ~/.ripgreprc)ls --hyperlink=autoThis tool is for commands without native support, like git status.
Use --hyperlink=auto (not always) for tools like ls. The auto option disables hyperlinks when piping to other commands, avoiding issues where escape sequences can interfere with downstream processing.
For more details, see this ripgrep discussion about hyperlink handling in pipes.
file:// hyperlinks~/ home directory expansionFrom crates.io:
cargo install add-osc-8-hyperlink
From GitHub:
cargo install --git https://github.com/konradko/add-osc-8-hyperlink-rs
Or build from source:
cargo build --release
cp target/release/add-osc-8-hyperlink ~/.local/bin/
Pipe any command output through the tool:
# Git status with colors and clickable file paths
git -c color.status=always status | add-osc-8-hyperlink
# Any command that outputs file paths
some-command | add-osc-8-hyperlink
Add to your .bashrc or .bash_profile:
function g { git -c color.status=always status "$@" | add-osc-8-hyperlink; }
Or for fish shell:
function git
if isatty stdout; and contains -- $argv[1] diff status log
command git -c color.status=always -c color.ui=always $argv | add-osc-8-hyperlink
return
end
command git $argv
end
The tool scans each line for file paths matching:
/tmp, /home, /usr, etc.)~/Paths are wrapped in OSC 8 escape sequences:
\e]8;;file://hostname/path\a<visible text>\e]8;;\a
ANSI color codes (\e[31m, etc.) are explicitly excluded from path matching, so colored output passes through unchanged.
Benchmarked against the Go implementation:
| Input Size | Rust | Go | Speedup |
|---|---|---|---|
| 5,000 lines | 15.7 ms | 37.6 ms | 2.4x faster |
| 50,000 lines | 103.3 ms | 306.1 ms | 3.0x faster |
Binary size: 1.6 MB (Rust) vs 2.8 MB (Go)
MIT