on master help sign in
Merge remote-tracking branch 'sharkdp/master'
commitf53ea60ed4cc47445239dab8bc6850016b22b32c authorDash Peters <dpeters@calacademy.org> dateThu 2 Jul 2020, 00:04 (6 years ago) parent5fdeeab05027b7
11 files changed+44−19
.gitmodules+4−1 CHANGELOG.md+6 Cargo.lock+3−3 README.md−8 assets/themes.bin assets/themes/gruvbox+1 src/controller.rs+1−1 src/printer.rs+16−6 tests/assets.rs+3 tests/examples/nonprintable.txt tests/integration_tests.rs+10
.gitmodules+4−1
@@ -185,6 +185,9 @@
185185[submodule "assets/syntaxes/02_Extra/AsciiDoc"]
186186 path = assets/syntaxes/02_Extra/AsciiDoc
187187 url = https://github.com/asciidoctor/sublimetext-asciidoc.git
188+[submodule "assets/themes/gruvbox"]
189+ path = assets/themes/gruvbox
190+ url = https://github.com/peaceant/gruvbox.git
188191[submodule "assets/syntaxes/02_Extra/GLSL"]
189192 path = assets/syntaxes/02_Extra/GLSL
190− url = https://github.com/euler0/sublime-glsl
193+ url = https://github.com/euler0/sublime-glsl
CHANGELOG.md+6
@@ -5,6 +5,9 @@
55- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
66
77## Bugfixes
8+
9+- Fixed non-printable characters display for redirected output, see #1061 (@gsomix)
10+
811## Other
912## Syntaxes
1013
@@ -12,6 +15,9 @@
1215- GLSL (@caioalonso)
1316
1417## New themes
18+
19+- Gruvbox, see #1069 (@kyleondy)
20+
1521## `bat` as a library
1622
1723- Add APIs to provide `Input` descriptions with `InputDescription` (@eth-p)
Cargo.lock+3−3
@@ -111,7 +111,7 @@ dependencies = [
111111 "predicates 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
112112 "semver 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
113113 "serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)",
114− "serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)",
114+ "serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)",
115115 "shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
116116 "syntect 4.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
117117 "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1035,7 +1035,7 @@ dependencies = [
10351035
10361036[[package]]
10371037name = "serde_yaml"
1038−version = "0.8.12"
1038+version = "0.8.13"
10391039source = "registry+https://github.com/rust-lang/crates.io-index"
10401040dependencies = [
10411041 "dtoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1458,7 +1458,7 @@ dependencies = [
14581458"checksum serde 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3"
14591459"checksum serde_derive 1.0.114 (registry+https://github.com/rust-lang/crates.io-index)" = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e"
14601460"checksum serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)" = "da07b57ee2623368351e9a0488bb0b261322a15a6e0ae53e243cbdc0f4208da9"
1461−"checksum serde_yaml 0.8.12 (registry+https://github.com/rust-lang/crates.io-index)" = "16c7a592a1ec97c9c1c68d75b6e537dcbf60c7618e038e7841e00af1d9ccf0c4"
1461+"checksum serde_yaml 0.8.13 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5"
14621462"checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
14631463"checksum shell-words 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
14641464"checksum smallvec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a"
README.md−8
@@ -316,14 +316,6 @@ You can download prebuilt binaries from the [Release page](https://github.com/sh
316316
317317You will need to install the [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) package.
318318
319−### Via Docker
320−
321−There is a [Docker image](https://hub.docker.com/r/danlynn/bat/) that you can use to run `bat` in a container:
322−```bash
323−docker pull danlynn/bat
324−alias bat='docker run -it --rm -e BAT_THEME -e BAT_STYLE -e BAT_TABS -v "$(pwd):/myapp" danlynn/bat'
325−```
326−
327319### From binaries
328320
329321Check out the [Release page](https://github.com/sharkdp/bat/releases) for
assets/themes.bin

Binary file not shown.

assets/themes/gruvboxnew file+1

Submodule changed.

src/controller.rs+1−1
@@ -113,7 +113,7 @@ impl<'b> Controller<'b> {
113113 };
114114
115115 let mut printer: Box<dyn Printer> = if self.config.loop_through {
116− Box::new(SimplePrinter::new())
116+ Box::new(SimplePrinter::new(&self.config))
117117 } else {
118118 Box::new(InteractivePrinter::new(
119119 &self.config,
src/printer.rs+16−6
@@ -52,15 +52,17 @@ pub(crate) trait Printer {
5252 ) -> Result<()>;
5353}
5454
55−pub struct SimplePrinter;
55+pub struct SimplePrinter<'a> {
56+ config: &'a Config<'a>
57+}
5658
57−impl SimplePrinter {
58− pub fn new() -> Self {
59− SimplePrinter {}
59+impl<'a> SimplePrinter<'a> {
60+ pub fn new(config: &'a Config) -> Self {
61+ SimplePrinter { config }
6062 }
6163}
6264
63−impl Printer for SimplePrinter {
65+impl<'a> Printer for SimplePrinter<'a> {
6466 fn print_header(
6567 &mut self,
6668 _handle: &mut dyn Write,
@@ -86,7 +88,15 @@ impl Printer for SimplePrinter {
8688 line_buffer: &[u8],
8789 ) -> Result<()> {
8890 if !out_of_range {
89− handle.write_all(line_buffer)?;
91+ if self.config.show_nonprintable {
92+ let line = replace_nonprintable(line_buffer, self.config.tab_width);
93+ write!(handle, "{}", line)?;
94+ if line_buffer.last() == Some(&b'\n') {
95+ writeln!(handle)?;
96+ }
97+ } else {
98+ handle.write_all(line_buffer)?
99+ };
90100 }
91101 Ok(())
92102 }
tests/assets.rs+3
@@ -29,6 +29,9 @@ fn all_themes_are_present() {
2929 "ansi-dark",
3030 "ansi-light",
3131 "base16",
32+ "gruvbox",
33+ "gruvbox-light",
34+ "gruvbox-white",
3235 "zenburn"
3336 ]
3437 );
tests/examples/nonprintable.txtnew file

Binary file not shown.

tests/integration_tests.rs+10
@@ -739,3 +739,13 @@ fn do_not_detect_different_syntax_for_stdin_and_files() {
739739 from_utf8(&cmd_for_stdin.get_output().stdout).expect("output is valid utf-8")
740740 );
741741}
742+
743+#[test]
744+fn show_all_mode() {
745+ bat()
746+ .arg("--show-all")
747+ .arg("nonprintable.txt")
748+ .assert()
749+ .stdout("hello•world␊\n├──┤␍␀␇␈␛")
750+ .stderr("");
751+}