Home > Net >  How to add hyperlinks to a terminal [ Node.js ]
How to add hyperlinks to a terminal [ Node.js ]

Time:09-24

I am looking to add a hyperlink within my terminal output using process.stdout.write() which is just a console.log() with a line break (\n) at the end of it.

What I have attempted so far:

  • console.log(`\e]8;;http://example.com\aThis is a hyperlink\e]8;;\a`);
    
  • process.stdout.write(`[This is a hyperlink](http://example.com)`);
    

Although the outputs remain undiffered from the whole string printing into my console.

Possible Duplicate Question - Does not answer my question

CodePudding user response:

There are some fully-featured terminal interfaces who can achieve this goal. But in general most terminal interfaces are Dumb Terminals, and don't support clickable hyperlinks.

The new Windows 1.4 Terminal will support hyperlinks, but it will release together with Windows 11.

A well documented Fully-Featured terminal is GNOME.

echo -e '\e]8;;http://example.com\aThis is a hyperlink\e]8;;\a'  

This is a code snippet if how to do to it in gnome, once you ctrl Click it, the hyperlink will redirect you to your desired page.

  • Related