HeadlinesBriefing favicon HeadlinesBriefing.com

Terminal Emulators Get Hyperlinks: OSC 8 Escape Sequence Explained

Hacker News •
×

Terminal emulators can now display clickable hyperlinks using the OSC 8 escape sequence, a feature that was previously impossible. Before 2017, URLs appearing in terminals could only be opened through auto-detection mechanisms like Ctrl+click or right-click menus. Now, arbitrary text can point to URLs just like on webpages.

GNOME Terminal and iTerm2 pioneered this capability, with most of the work happening in the VTE widget that powers many terminal emulators. The feature uses OSC 8 sequences where applications specify a target URI and optional parameters. The syntax is straightforward: OSC 8; params; URI ST, followed by cells that should be hyperlinked. Closing the link requires OSC 8; ; ST.

This opens practical applications like apt-changelog automatically linking bug IDs, git log making commit hashes clickable, and file viewers converting visible URIs to links. Core utilities could mark files with file:// URIs, and tools like less -R could handle these sequences like colors. The feature includes sophisticated handling for file:// URIs with hostname verification to prevent security issues when working remotely. Applications can also use the id parameter to group related text segments that should be underlined together when hovered.