Coder Social home page Coder Social logo

terminal-link's Introduction

terminal-link

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 stderr.

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.

Related

terminal-link's People

Contributors

bendingbender avatar colinking avatar danthegoodman avatar kyeotic avatar litomore avatar richienb avatar sindresorhus avatar tom-sherman avatar ulken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

terminal-link's Issues

I have error with dependencies "supports-hyperlinks"

why terminal-link is ESM, but supports-hyperlinks is commonjs ?
when i use terminal-link with ts-node xxx.ts, i get an error:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: xxxxx/node_modules/terminal-link/index.js

Add TypeScript definition

This is my typescript

declare function terminalLink(
  text: string,
  url: string,
  options?: { fallback: (text: string, url: string) => string }
): string;

declare module "terminal-link" {
  export = terminalLink;
}

3.0 doesn't support cjs

Providing a cjs build would be nice for those of use not able to use esm. In my case other tooling (qunit) is incompatible even though my lowest supported node version (12.x) is compatible with this.

Whats wrong ???

    const searches = await client.ft.search("idx:user",`@username:(${username})`,{ LIMIT : { size:perpage,from : offset } })

    if (searches.total === 0){

        console.log(`${chalk.bgRedBright(" NOTHING ")} founded`);

        process.exit(0)

        return;

    }

    for (const search of searches.documents){

        const item = search.value

        console.log(item);

        table.push([item.title,terminalLink("URL",item.url),Math.ceil(item.visit_duration / 1000),item.typed_count,item.hidden]);

    }

I am using cli-table and terminal link because of require I am using version 2.1.1
Screenshot 2023-09-08 at 6 17 54 PM

Clickable links including "zero width space" in URL

I've already reported this issue on the Netlify CLI repo netlify/cli#4311

I'm using VSCode and am working on a project that uses the Netlify CLI. They print out the URLs to the serverless functions as they're loaded. These URLs include a "zero width space" (U+200B).

◈ Loaded function api (​http://localhost:8888/.netlify/functions/api​).
◈ Loaded function render (​http://localhost:8888/.netlify/functions/render​).

Clicking those links in the VSCode terminal includes the zero width space, producing URLs that look like

http://localhost:8888/.netlify/functions/api%E2%80%8B

I know there is a fallback that adds the character for unsupported terminals. VSCode isn't specifically on the support list, but it can also use lots of different terminals so it may be listed as one of them. Even if none are supported, VSCode's terminal seems to make any URL-like string clickable, for example:

image

I'm curious if it would be safe for me to write a PR for the Netlify CLI that turns it off or returns a normal space?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.