mirror of https://github.com/sharkdp/fd.git
Only parse dir_colors if output is colored, closes #21
This commit is contained in:
parent
bb63a4c6d7
commit
f9cb3326c8
17
src/main.rs
17
src/main.rs
|
@ -233,9 +233,17 @@ fn main() {
|
||||||
};
|
};
|
||||||
let current_dir = current_dir_buf.as_path();
|
let current_dir = current_dir_buf.as_path();
|
||||||
|
|
||||||
let ext_styles = env::home_dir()
|
let colored_output = !matches.opt_present("no-color") &&
|
||||||
.map(|h| h.join(".dir_colors"))
|
stdout_isatty();
|
||||||
.and_then(|path| parse_dircolors(&path).ok());
|
|
||||||
|
let ext_styles =
|
||||||
|
if colored_output {
|
||||||
|
env::home_dir()
|
||||||
|
.map(|h| h.join(".dir_colors"))
|
||||||
|
.and_then(|path| parse_dircolors(&path).ok())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let config = FdOptions {
|
let config = FdOptions {
|
||||||
// The search will be case-sensitive if the command line flag is set or
|
// The search will be case-sensitive if the command line flag is set or
|
||||||
|
@ -244,8 +252,7 @@ fn main() {
|
||||||
pattern.chars().any(char::is_uppercase),
|
pattern.chars().any(char::is_uppercase),
|
||||||
search_full_path: !matches.opt_present("filename"),
|
search_full_path: !matches.opt_present("filename"),
|
||||||
search_hidden: matches.opt_present("hidden"),
|
search_hidden: matches.opt_present("hidden"),
|
||||||
colored: !matches.opt_present("no-color") &&
|
colored: colored_output,
|
||||||
stdout_isatty(),
|
|
||||||
follow_links: matches.opt_present("follow"),
|
follow_links: matches.opt_present("follow"),
|
||||||
max_depth:
|
max_depth:
|
||||||
matches.opt_str("max-depth")
|
matches.opt_str("max-depth")
|
||||||
|
|
Loading…
Reference in New Issue