diff --git a/src/app.rs b/src/app.rs index 0e61cc7d50..a9ac691e13 100644 --- a/src/app.rs +++ b/src/app.rs @@ -263,8 +263,8 @@ impl App { .overrides_with("wrap") .takes_value(true) .value_name("mode") - .possible_values(&["character", "never"]) - .default_value("character") + .possible_values(&["auto", "never", "character"]) + .default_value("auto") .help("Specify the text-wrapping mode.") .long_help("Specify the text-wrapping mode."), ).arg( @@ -339,10 +339,10 @@ impl App { pub fn config(&self) -> Result { let files = self.files(); + let output_components = self.output_components()?; Ok(Config { true_color: is_truecolor_terminal(), - output_components: self.output_components()?, language: self.matches.value_of("language"), output_wrap: if !self.interactive_output { // We don't have the tty width when piping to another program. @@ -351,7 +351,12 @@ impl App { } else { match self.matches.value_of("wrap") { Some("character") => OutputWrap::Character, - Some("never") | _ => OutputWrap::None, + Some("never") => OutputWrap::None, + Some("auto") | _ => if output_components.plain() { + OutputWrap::None + } else { + OutputWrap::Character + }, } }, colored_output: match self.matches.value_of("color") { @@ -395,6 +400,7 @@ impl App { .or_else(|| env::var("BAT_THEME").ok()) .unwrap_or(String::from(BAT_THEME_DEFAULT)), line_range: transpose(self.matches.value_of("line-range").map(LineRange::from))?, + output_components, }) } diff --git a/src/style.rs b/src/style.rs index 4c36265d17..efd83697b1 100644 --- a/src/style.rs +++ b/src/style.rs @@ -78,4 +78,8 @@ impl OutputComponents { pub fn numbers(&self) -> bool { self.0.contains(&OutputComponent::Numbers) } + + pub fn plain(&self) -> bool { + self.0.is_empty() + } }