link

The link function creates a clickable hyperlink in terminal emulators that support the OSC 8 escape sequence. The link text is displayed in the terminal and opens the URL when clicked.

Example of ts-better-console link function in action

Signature

function link(text: string, url: string): string

Parameters

  • text: The display text shown in the terminal.
  • url: The URL that opens when the link is clicked.

Return Value

Returns a string containing OSC 8 escape sequences that render as a clickable hyperlink in supported terminals.

Usage

import betterConsole, { link } from "ts-better-console";

// Create a clickable link in the terminal
betterConsole.log(link("Visit GitHub", "https://github.com"));

// Combine with styled text
betterConsole.log("Check out", link("the docs", "https://example.com/docs"));

Want to support this project?

If you find ts-better-console useful and want to support its development, consider starring the GitHub repository or buying me a coffee! Your support helps me dedicate more time to improving the library and adding new features.

Want to contribute to this project?

Contributions are welcome! If you're interested in improving the library, fixing bugs, or adding new features, feel free to check out the GitHub repository and submit a pull request. Whether you're a seasoned developer or new to open source, your contributions can make a difference!