mirror of https://github.com/sharkdp/fd.git
Windows: Always enable colors if --color=always is set
This commit is contained in:
parent
d77daa89a2
commit
53c338d71f
12
src/main.rs
12
src/main.rs
|
@ -148,18 +148,22 @@ fn run() -> Result<ExitCode> {
|
||||||
let case_sensitive = !matches.is_present("ignore-case")
|
let case_sensitive = !matches.is_present("ignore-case")
|
||||||
&& (matches.is_present("case-sensitive") || pattern_has_uppercase_char(&pattern_regex));
|
&& (matches.is_present("case-sensitive") || pattern_has_uppercase_char(&pattern_regex));
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
let ansi_colors_support = ansi_term::enable_ansi_support().is_ok();
|
||||||
|
|
||||||
|
#[cfg(not(windows))]
|
||||||
|
let ansi_colors_support = true;
|
||||||
|
|
||||||
let interactive_terminal = atty::is(Stream::Stdout);
|
let interactive_terminal = atty::is(Stream::Stdout);
|
||||||
let colored_output = match matches.value_of("color") {
|
let colored_output = match matches.value_of("color") {
|
||||||
Some("always") => true,
|
Some("always") => true,
|
||||||
Some("never") => false,
|
Some("never") => false,
|
||||||
_ => env::var_os("NO_COLOR").is_none() && interactive_terminal,
|
_ => ansi_colors_support && env::var_os("NO_COLOR").is_none() && interactive_terminal,
|
||||||
};
|
};
|
||||||
|
|
||||||
let path_separator = matches.value_of("path-separator").map(|str| str.to_owned());
|
let path_separator = matches.value_of("path-separator").map(|str| str.to_owned());
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
let colored_output = colored_output && ansi_term::enable_ansi_support().is_ok();
|
|
||||||
|
|
||||||
let ls_colors = if colored_output {
|
let ls_colors = if colored_output {
|
||||||
Some(LsColors::from_env().unwrap_or_default())
|
Some(LsColors::from_env().unwrap_or_default())
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue