diff --git a/.gitmodules b/.gitmodules index d619f27a..1bf1bc60 100644 --- a/.gitmodules +++ b/.gitmodules @@ -185,6 +185,9 @@ [submodule "assets/syntaxes/02_Extra/AsciiDoc"] path = assets/syntaxes/02_Extra/AsciiDoc url = https://github.com/asciidoctor/sublimetext-asciidoc.git +[submodule "assets/themes/gruvbox"] + path = assets/themes/gruvbox + url = https://github.com/peaceant/gruvbox.git [submodule "assets/syntaxes/02_Extra/GLSL"] path = assets/syntaxes/02_Extra/GLSL - url = https://github.com/euler0/sublime-glsl + url = https://github.com/euler0/sublime-glsl \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a168c47..f9d45641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p) ## Bugfixes + +- Fixed non-printable characters display for redirected output, see #1061 (@gsomix) + ## Other ## Syntaxes @@ -12,6 +15,9 @@ - GLSL (@caioalonso) ## New themes + +- Gruvbox, see #1069 (@kyleondy) + ## `bat` as a library - Add APIs to provide `Input` descriptions with `InputDescription` (@eth-p) diff --git a/Cargo.lock b/Cargo.lock index 08e27065..379ba691 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,7 +111,7 @@ dependencies = [ "predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "semver 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)", "shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "syntect 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1035,7 +1035,7 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1458,7 +1458,7 @@ dependencies = [ "checksum serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" "checksum serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" "checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9" -"checksum serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)" = "16c7a592a1ec97c9c1c68d75b6e537dcbf60c7618e038e7841e00af1d9ccf0c4" +"checksum serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5" "checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" "checksum shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074" "checksum smallvec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a" diff --git a/README.md b/README.md index 23783c11..e52d5525 100644 --- a/README.md +++ b/README.md @@ -316,14 +316,6 @@ You can download prebuilt binaries from the [Release page](https://github.com/sh You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package. -### Via Docker - -There is a [Docker image](https://hub.docker.com/r/danlynn/bat/) that you can use to run `bat` in a container: -```bash -docker pull danlynn/bat -alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat' -``` - ### From binaries Check out the [Release page](https://github.com/sharkdp/bat/releases) for diff --git a/assets/themes.bin b/assets/themes.bin index 9de98391..076b1a13 100644 Binary files a/assets/themes.bin and b/assets/themes.bin differ diff --git a/assets/themes/gruvbox b/assets/themes/gruvbox new file mode 160000 index 00000000..e3db74d0 --- /dev/null +++ b/assets/themes/gruvbox @@ -0,0 +1 @@ +Subproject commit e3db74d0e5de7bc09cab76377723ccf6bcc64e8c diff --git a/src/controller.rs b/src/controller.rs index e11080f5..3fe44a72 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -113,7 +113,7 @@ impl<'b> Controller<'b> { }; let mut printer: Box = if self.config.loop_through { - Box::new(SimplePrinter::new()) + Box::new(SimplePrinter::new(&self.config)) } else { Box::new(InteractivePrinter::new( &self.config, diff --git a/src/printer.rs b/src/printer.rs index addc7972..7e369a6e 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -52,15 +52,17 @@ pub(crate) trait Printer { ) -> Result<()>; } -pub struct SimplePrinter; +pub struct SimplePrinter<'a> { + config: &'a Config<'a> +} -impl SimplePrinter { - pub fn new() -> Self { - SimplePrinter {} +impl<'a> SimplePrinter<'a> { + pub fn new(config: &'a Config) -> Self { + SimplePrinter { config } } } -impl Printer for SimplePrinter { +impl<'a> Printer for SimplePrinter<'a> { fn print_header( &mut self, _handle: &mut dyn Write, @@ -86,7 +88,15 @@ impl Printer for SimplePrinter { line_buffer: &[u8], ) -> Result<()> { if !out_of_range { - handle.write_all(line_buffer)?; + if self.config.show_nonprintable { + let line = replace_nonprintable(line_buffer, self.config.tab_width); + write!(handle, "{}", line)?; + if line_buffer.last() == Some(&b'\n') { + writeln!(handle)?; + } + } else { + handle.write_all(line_buffer)? + }; } Ok(()) } diff --git a/tests/assets.rs b/tests/assets.rs index ab0f7686..1c8408b4 100644 --- a/tests/assets.rs +++ b/tests/assets.rs @@ -29,6 +29,9 @@ fn all_themes_are_present() { "ansi-dark", "ansi-light", "base16", + "gruvbox", + "gruvbox-light", + "gruvbox-white", "zenburn" ] ); diff --git a/tests/examples/nonprintable.txt b/tests/examples/nonprintable.txt new file mode 100644 index 00000000..00f60e33 Binary files /dev/null and b/tests/examples/nonprintable.txt differ diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 7991083b..730974c9 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -739,3 +739,13 @@ fn do_not_detect_different_syntax_for_stdin_and_files() { from_utf8(&cmd_for_stdin.get_output().stdout).expect("output is valid utf-8") ); } + +#[test] +fn show_all_mode() { + bat() + .arg("--show-all") + .arg("nonprintable.txt") + .assert() + .stdout("hello•world␊\n├──┤␍␀␇␈␛") + .stderr(""); +}