https://github.com/hougesen/terminal_link
Easily create clickable terminal hyperlinks in Gleam programs
https://github.com/hougesen/terminal_link
cli gleam terminal
Last synced: 9 months ago
JSON representation
Easily create clickable terminal hyperlinks in Gleam programs
- Host: GitHub
- URL: https://github.com/hougesen/terminal_link
- Owner: hougesen
- License: mit
- Created: 2025-03-19T14:23:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-20T04:30:51.000Z (over 1 year ago)
- Last Synced: 2025-10-11T20:03:51.035Z (9 months ago)
- Topics: cli, gleam, terminal
- Language: Gleam
- Homepage: https://hex.pm/packages/terminal_link
- Size: 9.77 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# terminal_link
[](https://hex.pm/packages/terminal_link)
[](https://hexdocs.pm/terminal_link/)
Easily create clickable terminal hyperlinks in Gleam programs.
`terminal_link` is a loose port of [https://github.com/mainrs/terminal-link-rs](https://github.com/mainrs/terminal-link-rs) and [https://github.com/zkat/supports-hyperlinks](https://github.com/zkat/supports-hyperlinks) to Gleam.
```bash
gleam add terminal_link
```
## Printing a hyperlink to terminal
```gleam
import 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))
}
```
## Validating a terminal supports terminal links
```gleam
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 .
## Development
```bash
# Run the project
gleam run
# Run the tests
gleam test
```