You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

terminal-link

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terminal-link

Create clickable links in the terminal


Version published
Weekly downloads
9.8M
decreased by-1.36%
Maintainers
1
Install size
180 kB
Created
Weekly downloads
 

Package description

What is terminal-link?

The terminal-link npm package allows you to create clickable links in the terminal. This can be useful for providing users with easy access to URLs directly from the command line.

What are terminal-link's main functionalities?

Basic Link Creation

This feature allows you to create a basic clickable link in the terminal. The link text ('My Website') will be clickable and will direct the user to the specified URL ('https://example.com').

const terminalLink = require('terminal-link');
const link = terminalLink('My Website', 'https://example.com');
console.log(link);

Conditional Link Creation

This feature allows you to create a link that only becomes clickable if the terminal supports it. If not, it will fall back to a plain text URL.

const terminalLink = require('terminal-link');
const link = terminalLink.isSupported ? terminalLink('My Website', 'https://example.com') : 'My Website (https://example.com)';
console.log(link);

Customizing Link Styles

This feature allows you to customize the appearance of the link text using other libraries like chalk. In this example, the link text is styled to be blue and underlined.

const terminalLink = require('terminal-link');
const chalk = require('chalk');
const link = terminalLink(chalk.blue.underline('My Website'), 'https://example.com');
console.log(link);

Other packages similar to terminal-link

Readme

Source

Create clickable links in the terminal

Install

$ npm install terminal-link

Usage

import terminalLink from 'terminal-link';

const link = terminalLink('My Website', 'https://sindresorhus.com');
console.log(link);

API

terminalLink(text, url, options?)

Create a link for use in stdout.

Supported terminals.

For unsupported terminals, the link will be printed in parens after the text: My website (https://sindresorhus.com).

text

Type: string

Text to linkify.

url

Type: string

URL to link to.

options

Type: object

fallback

Type: Function | boolean

Override the default fallback. The function receives the text and url as parameters and is expected to return a string.

If set to false, the fallback will be disabled when a terminal is unsupported.

terminalLink.isSupported

Type: boolean

Check whether the terminal's stdout supports links.

Prefer just using the default fallback or the fallback option whenever possible.

terminalLink.stderr(text, url, options?)

Create a link for use in stdout.

Same arguments as terminalLink().

terminalLink.stderr.isSupported

Type: boolean

Check whether the terminal's stderr supports links.

Prefer just using the default fallback or the fallback option whenever possible.

  • terminal-link-cli - CLI for this module
  • ink-link - Link component for Ink
  • chalk - Terminal string styling done right

Keywords

FAQs

Package last updated on 18 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc