Easily create clickable terminal hyperlinks in Gleam programs.
terminal_link is a loose port of https://github.com/mainrs/terminal-link-rs and https://github.com/zkat/supports-hyperlinks to Gleam.
gleam add terminal_linkimport gleam/io
import gleam/option.{type Option, None}
import terminal_link.{
TerminalLink, terminal_link_to_string, terminal_supports_links,
}
fn main() {
let destination = "https://github.com/hougesen"
let text = "github.com/hougesen"
let id: Option(String) = None
let link = TerminalLink(destination, text, id)
io.println(terminal_link_to_string(link))
}import gleam/io
import gleam/option.{None}
import terminal_link.{TerminalLink, terminal_link_to_string}
fn main() {
let destination = "https://github.com/hougesen"
let link = TerminalLink(destination, "github.com/hougesen", None)
case terminal_supports_links() {
// Print the clickable link if the terminal supports it
True -> io.println(terminal_link_to_string(link))
// Or use the full link as fallback
False -> io.println(destination)
}
}Further documentation can be found at https://hexdocs.pm/terminal_link.
# Run the project
gleam run
# Run the tests
gleam test