1. supports-hyperlinks
Detect if your terminal emulator supports hyperlinks
supports-hyperlinks
Package: supports-hyperlinks
Created by: jamestalmage
Last modified: Wed, 12 Apr 2023 02:46:14 GMT
Version: 3.0.0
License: MIT
Downloads: 70,840,606
Repository: https://github.com/jamestalmage/supports-hyperlinks

Install

npm install supports-hyperlinks
yarn add supports-hyperlinks

supports-hyperlinks Build Status codecov

Detect whether a terminal emulator supports hyperlinks

Terminal emulators are starting to support hyperlinks. While many terminals have long detected URL's and linkified them, allowing you to Command-Click or Control-Click them to open a browser, you were forced to print the long unsightly URL's on the screen. As of spring 2017 a few terminals began supporting HTML like links, where the link text and destination could be specified separately.

This module allows you to detect if hyperlinks are supported in the current Terminal.

As this is a new development, we anticipate the list of supported Terminals to grow rapidly. Please open an issue or submit a PR as new Terminals implement support.

Install

$ npm install supports-hyperlinks

Usage

 const supportsHyperlinks = require('supports-hyperlinks');

if (supportsHyperlinks.stdout) {
	console.log('Terminal stdout supports hyperlinks');
}

if (supportsHyperlinks.stderr) {
	console.log('Terminal stderr supports hyperlinks');
}

API

Returns an Object with a stdout and stderr property for testing either streams. Each property is a boolean, indicating whether or not hyperlinks are supported.

Info

Obeys the --no-hyperlinks, --hyperlink=always, and --hyperlink=never CLI flags.

Can be overridden by the user with the flags --hyperlinks=always and --no-hyperlinks. For situations where using those flags are not possible, add the environment variable FORCE_HYPERLINK=1 to forcefully enable hyperlinks or FORCE_HYPERLINK=0 to forcefully disable. The use of FORCE_HYPERLINK overrides all other hyperlink support checks.

License

MIT © James Talmage

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code