Skip to main content
ansicode

OSC 8 — Inline hyperlink

Render clickable hyperlinks in terminal output (gnome-terminal 3.26+, iTerm2, Windows Terminal, kitty, ...).

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b]8;;URI\x07TEXT\x1b]8;;\x07
\\033[\033]8;;URI\007TEXT\033]8;;\007
\\e[\e]8;;URI\aTEXT\e]8;;\a
ESC [ESC ] 8 ; ; URI BEL TEXT ESC ] 8 ; ; BEL
hex1b 5d 38 3b 3b ... 07 ... 1b 5d 38 3b 3b 07

Description

Specified by gnome-terminal in 2017 and now widely adopted. Two-part sequence: `OSC 8 ; params ; URI BEL` opens a link region, `OSC 8 ; ; BEL` (empty URI) closes it. The middle TEXT can include any printable + further SGR. Optional params: `id=anchor` lets the terminal de-duplicate multi-line links. Plain HTTP/HTTPS URIs work everywhere; `file://` works in iTerm2 / wezterm / kitty / vscode-terminal; `vscode://` and editor URIs are supported by some.

Spec citation: Hyperlinks in terminal emulators (gnome-terminal proposal, 2017)

Examples

bash
printf '\033]8;;https://example.com\033\\link text\033]8;;\033\\\n'
python
print('\x1b]8;;https://example.com\x07link text\x1b]8;;\x07')
go
fmt.Print("\x1b]8;;https://example.com\x07link text\x1b]8;;\x07\n")
javascript
console.log('\x1b]8;;https://example.com\x07link text\x1b]8;;\x07')
c
printf("\x1b]8;;https://example.com\x07link text\x1b]8;;\x07\n");

Terminal support

xterm
partial
Linux console (fbcon)
no
macOS Terminal.app
no
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
no
kitty
yes
alacritty
no
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

OSC cookbook · 3. OSC 8 hyperlinks — `\x1b]8;;URI\x07TEXT\x1b]8;;\x07`