1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#![doc = include_str!("../README.md")]
pub use atty::Stream;
pub fn supports_hyperlinks() -> bool {
if std::env::var("DOMTERM").is_ok() {
true
} else if let Ok(version) = std::env::var("VTE_VERSION") {
version.parse().unwrap_or(0) >= 5000
} else if let Ok(program) = std::env::var("TERM_PROGRAM") {
matches!(
&program[..],
"Hyper" | "iTerm.app" | "terminology" | "WezTerm"
)
} else if let Ok(term) = std::env::var("TERM") {
matches!(&term[..], "xterm-kitty")
} else {
std::env::var("WT_SESSION").is_ok() ||
std::env::var("KONSOLE_VERSION").is_ok()
}
}
pub fn on(stream: Stream) -> bool {
atty::is(stream) && supports_hyperlinks()
}