DEV Community

Valeria
Valeria

Posted on

3

Day 17: Terminal Links & Other Escapes πŸ”—

Ever wondered how to make a clickable link in a terminal? Well you don't have to wonder no more: you can use special ANSI code for it!
And ansi-escapes have you covered!

Install the package with e.g. deno add npm:ansi-escapes and create a file, e.g. main.ts:

import {link as createLink} from "ansi-escapes";

const link = createLink("link", "https://valeriavg.dev");

console.log(`Hello! Would you like to check this ${link} perhaps?`);
Enter fullscreen mode Exit fullscreen mode

Run with e.g. deno run -A ./main.ts and enjoy:

VSCode Terminal with a link

The screenshot is from VSCode terminal, but not every terminal would support links!

On Mac, for example, iTerm2 would support it:

iTerm2

But default terminal app would not:

Mac terminal

There are other libraries that would help you detect if a feature is supported or not and ansi-escapes comes with a lot of features!

Check it out and do share your creations!

Liked the content and would love to have more of it all year long?

Buy Me A Coffee

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

πŸ‘₯ Ideal for solo developers, teams, and cross-company projects

Learn more

πŸ‘‹ Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Communityβ€”every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple β€œthank you” goes a long wayβ€”express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay