diff --git a/Cargo.toml b/Cargo.toml index 6401aaf21..7b00e806b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ syntect = "5.0.0" # sysinfo: no default features to disable the use of threads sysinfo = { version = "0.29.0", default-features = false, features = [] } terminal-colorsaurus = "0.4.1" +terminfo = "0.9.0" unicode-segmentation = "1.10.1" unicode-width = "=0.1.12" xdg = "2.4.1" diff --git a/src/options/set.rs b/src/options/set.rs index 6d26d15df..0a0025d38 100644 --- a/src/options/set.rs +++ b/src/options/set.rs @@ -662,10 +662,15 @@ fn set_true_color(opt: &mut cli::Opt) { } fn is_truecolor_terminal(env: &DeltaEnv) -> bool { - env.colorterm + let rgb_cap = terminfo::Database::from_env() + .map(|db| db.raw("RGB").is_some()) + .unwrap_or(false); + let colorterm = env + .colorterm .as_ref() .map(|colorterm| colorterm == "truecolor" || colorterm == "24bit") - .unwrap_or(false) + .unwrap_or(false); + rgb_cap || colorterm } #[cfg(test)]