You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40-6Lines changed: 40 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
14
14
**Termlink is a Go package that allows you to create fully customizable clickable links in the terminal. It is the Go version of Sindre Sorhus' popular [terminal-link](https://github.com/sindresorhus/terminal-link/) library.**
15
15
16
-
**It includes multiple features including dynamic and fully customizable colored links in terminal.**
16
+
**It includes multiple features including dynamic and fully customizable colored links in terminal, along with smart hyperlink support detection.**
17
17
18
18
## 🛠️ Install
19
19
@@ -55,7 +55,22 @@ func main() {
55
55
}
56
56
```
57
57
58
-
- You can also use this package in combination with another popular Go package [fatih/color](https://github.com/fatih/color)
58
+
- Check if your current terminal supports hyperlinks:
// prints either true or false, depending on your terminal
70
+
}
71
+
```
72
+
73
+
- Since `termlink.Link` returns a string, you can use it with your favorite text color formatting libraries such as [fatih/color](https://github.com/fatih/color), [mgutz/ansi](https://github.com/mgutz/ansi), etc. Alternatively, you can use `termlink.ColorLink` as well.
59
74
60
75
```go
61
76
import (
@@ -67,11 +82,12 @@ import (
67
82
68
83
funcmain() {
69
84
// With fatih/color package
70
-
color.Cyan(termlink.Link("Example link using the colors package", "https://example.com"))
85
+
color.Cyan(termlink.Link("Example link using the fatih/color package", "https://example.com"))
71
86
}
72
87
```
73
88
74
-
> #### Note: For unsupported terminals, the link will be printed in parentheses after the text (see below image)
89
+
> **Note**
90
+
> **For unsupported terminals, the link will be printed in parentheses after the text (see below image)**
go get github.com/savioxavier/termlink
106
+
go run examples/start.go
107
+
```
108
+
84
109
---
85
110
86
111
## 🔮 Features
@@ -101,6 +126,15 @@ More examples can be found in the [`examples/`](examples/) directory.
101
126
- With formatting: `green bold`, `red bgGreen italic`, `italic blue bgGreen`, etc.
102
127
- The `shouldForce` is an optional boolean parameter which allows you to force the above unsupported terminal hyperlinks format `text (url)` to be printed, even in supported terminals
103
128
129
+
> `shouldForce` can be used in the following manner:
130
+
>
131
+
> ```go
132
+
> termlink.Link(text, url, true)
133
+
> termlink.ColorLink(text, url, color, true)
134
+
> ```
135
+
>
136
+
> You don't always need to specify this argument. By default, this parameter is `false`
137
+
104
138
- **`termlink.SupportsHyperlinks()`**:
105
139
106
140
- Returns `true` if the terminal supports hyperlinks, `false` otherwise.
@@ -109,7 +143,7 @@ More examples can be found in the [`examples/`](examples/) directory.
109
143
110
144
## 🧪 Tests
111
145
112
-
You can run unit tests _locally_ by running the following command
146
+
You can run unit tests _locally_ by running the following command:
113
147
114
148
```bash
115
149
go test -v
@@ -136,6 +170,6 @@ You can support further development of this project by **giving it a 🌟** and
136
170
## 💫 Attributions and special thanks
137
171
138
172
-[terminal-link](https://github.com/sindresorhus/terminal-link) - Sindre Sorhus' original package for providing inspiration for this package.
139
-
-[go-supportscolor](https://github.com/jwalton/go-supportscolor) - A package for detecting terminal color support.
173
+
-[supports-hyperlinks](https://github.com/zkat/supports-hyperlinks) - Zkat's package for additional hyperlink handling support.
140
174
141
175
<sub><sup>* The paperclip icon shown in the demo at the top of this README isn't included when you create the link, it's purely for decorative purposes only.</sup></sub>
0 commit comments