From 026273a05c50f9067598ffd6a58b2ad9913f7864 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sat, 1 Sep 2018 00:01:07 +0200 Subject: [PATCH] Enable ANSI support on Windows --- src/app.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app.rs b/src/app.rs index 37fbd530..2fbe223f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -335,6 +335,15 @@ impl App { pub fn config(&self) -> Result { let files = self.files(); + let colored_output = match self.matches.value_of("color") { + Some("always") => true, + Some("never") => false, + Some("auto") | _ => self.interactive_output, + }; + + #[cfg(windows)] + let colored_output = colored_output && ansi_term::enable_ansi_support().is_ok(); + Ok(Config { true_color: is_truecolor_terminal(), output_components: self.output_components()?, @@ -349,11 +358,7 @@ impl App { Some("never") | _ => OutputWrap::None, } }, - colored_output: match self.matches.value_of("color") { - Some("always") => true, - Some("never") => false, - Some("auto") | _ => self.interactive_output, - }, + colored_output, paging_mode: match self.matches.value_of("paging") { Some("always") => PagingMode::Always, Some("never") => PagingMode::Never,