mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	Merge remote-tracking branch 'sharkdp/master'
This commit is contained in:
		
							
								
								
									
										5
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@@ -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
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@@ -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"
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								assets/themes.bin
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								assets/themes.bin
									
									
									
									
										vendored
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										1
									
								
								assets/themes/gruvbox
									
									
									
									
										vendored
									
									
										Submodule
									
								
							
							
								
								
								
								
								
							
						
						
									
										1
									
								
								assets/themes/gruvbox
									
									
									
									
										vendored
									
									
										Submodule
									
								
							 Submodule assets/themes/gruvbox added at e3db74d0e5
									
								
							@@ -113,7 +113,7 @@ impl<'b> Controller<'b> {
 | 
			
		||||
                    };
 | 
			
		||||
 | 
			
		||||
                    let mut printer: Box<dyn Printer> = if self.config.loop_through {
 | 
			
		||||
                        Box::new(SimplePrinter::new())
 | 
			
		||||
                        Box::new(SimplePrinter::new(&self.config))
 | 
			
		||||
                    } else {
 | 
			
		||||
                        Box::new(InteractivePrinter::new(
 | 
			
		||||
                            &self.config,
 | 
			
		||||
 
 | 
			
		||||
@@ -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(())
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -29,6 +29,9 @@ fn all_themes_are_present() {
 | 
			
		||||
            "ansi-dark",
 | 
			
		||||
            "ansi-light",
 | 
			
		||||
            "base16",
 | 
			
		||||
            "gruvbox",
 | 
			
		||||
            "gruvbox-light",
 | 
			
		||||
            "gruvbox-white",
 | 
			
		||||
            "zenburn"
 | 
			
		||||
        ]
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								tests/examples/nonprintable.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								tests/examples/nonprintable.txt
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -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("");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user