How I Turned Terminal Output into Clickable Links

I regularly write scripts that produce various links to logs and related assets. Over time, I grew tired of copying and pasting these URLs into my browser. Eventually, I wondered if I could make them clickable directly in the terminal.

Thank me by sharing on Twitter πŸ™

First, I tried the usual link syntax but discovered that most terminals ignore Markdown formatting. Then, I found out about OSC 8 escape sequences. This special sequence allows certain modern terminals to show text as a hyperlink. Here’s the general idea:

Plaintext
myUrl="https://example.com"
echo -e "\033]8;;${myUrl}\007Click Me!\033]8;;\007"

When the script runs, the β€œClick Me!” part shows up as a clickable link. In supported terminals, one click will open the URL in the default browser. This tiny change made a huge difference in my day-to-day workflow because now I can jump directly to the relevant resource without any extra steps.

In conclusion, adding clickable links to my terminal output proved invaluable. It saves me time, minimizes manual work, and keeps me organized. If you often find yourself dealing with multiple URLs in your scripts, give this approach a tryβ€”you might be surprised at just how much of a productivity boost it can offer.

Share this:

Leave a Reply