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?`);
Run with e.g. deno run -A ./main.ts
and enjoy:
The screenshot is from VSCode terminal, but not every terminal would support links!
On Mac, for example, iTerm2 would support it:
But default terminal app would not:
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?
Top comments (0)