diff --git a/Cargo.toml b/Cargo.toml index 94d3f78..b344542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ no-color = [] [dependencies] atty = "0.2" lazy_static = "1" +terminfo = "0.7" [target.'cfg(windows)'.dependencies.winapi] version = "0.3" diff --git a/src/control.rs b/src/control.rs index 955aa2d..e57c9cb 100644 --- a/src/control.rs +++ b/src/control.rs @@ -104,8 +104,15 @@ impl ShouldColorize { /// followed by `CLICOLOR` combined with tty check. pub fn from_env() -> Self { ShouldColorize { - clicolor: ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true) - && atty::is(atty::Stream::Stdout), + clicolor: (ShouldColorize::normalize_env(env::var("CLICOLOR")).unwrap_or(true)) + && atty::is(atty::Stream::Stdout) + && (if let Ok(db) = terminfo::Database::from_env() { + db.get::() + .map(|mc| 2 < mc.into()) + .unwrap_or(false) + } else { + true + }), clicolor_force: ShouldColorize::resolve_clicolor_force( env::var("NO_COLOR"), env::var("CLICOLOR_FORCE"),