about summary refs log tree commit diff
path: root/internal/terminal/link.go
blob: a50b199d11e2545037e9662f3bb069134a35c9c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
package terminal

import "fmt"

// Link returns a formatted string that represents a hyperlink.
// The hyperlink is created using the escape sequence for terminal emulators.
// The text parameter represents the visible text of the hyperlink,
// and the url parameter represents the URL that the hyperlink points to.
// For more information on the escape sequence, refer to:
// https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence
func Link(text string, url string) string {
	return fmt.Sprintf("\x1b]8;;%s\x07%s\x1b]8;;\x07\u001b[0m", url, text)
}