diff --git a/Cargo.toml b/Cargo.toml index 4a462336..6b21af22 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ features = ["suggestions", "color", "wrap_help"] [build-dependencies] clap = "2" +output_vt100 = "0.1" [[bin]] name = "pastel" diff --git a/src/cli/cli.rs b/src/cli/cli.rs index a4499641..ba25d985 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -485,7 +485,7 @@ pub fn build_cli() -> App<'static, 'static> { .value_name("mode") .help("Specify the terminal color mode: 24bit, 8bit, off, *auto*") .possible_values(&["24bit", "8bit", "off", "auto"]) - .default_value("auto") + .default_value(if output_vt100::try_init().is_ok() {"auto"} else {"off"}) .hide_possible_values(true) .hide_default_value(true) ) diff --git a/src/cli/main.rs b/src/cli/main.rs index 87758cf9..f9f31585 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -39,10 +39,6 @@ fn run() -> Result { let interactive_mode = atty::is(Stream::Stdout); - if interactive_mode { - output_vt100::init(); - } - let color_mode = if global_matches.is_present("force-color") { Some(ansi::Mode::TrueColor) } else {