diff --git a/CHANGELOG.md b/CHANGELOG.md index 51877e30..fca99cb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ # unreleased ## Features + +- Add padding above headers when not using a grid, see #968 and #981 (@pt2121) + ## Bugfixes + +- bat mishighlights Users that start with digits in SSH config, see #984 + ## Other ## New syntaxes ## New themes diff --git a/Cargo.lock b/Cargo.lock index 3ac9abd5..f5abaf3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "bat" -version = "0.15.0" +version = "0.15.1" dependencies = [ "ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index a62bbe2e..ff8e4fa3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ license = "MIT/Apache-2.0" name = "bat" readme = "README.md" repository = "https://github.com/sharkdp/bat" -version = "0.15.0" +version = "0.15.1" exclude = [ "assets/syntaxes/*", "assets/themes/*", diff --git a/README.md b/README.md index 5972806f..0bf2f6b3 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat. [![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions) -### On Ubuntu +### On Ubuntu (using `apt`) *... and other Debian-based Linux distributions.* `bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and @@ -182,12 +182,22 @@ If your Ubuntu/Debian installation is new enough you can simply run: apt install bat ``` +If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name +clash with another package](https://github.com/sharkdp/bat/issues/982)). You can set up a `bat -> batcat` symlink or alias to prevent any issues that may come up because of this and to be consistent with other distrutions: +``` bash +mkdir -p ~/.local/bin +ln -s /usr/bin/batcat ~/.local/bin/bat +``` + +### On Ubuntu (using most recent `.deb` packages) +*... and other Debian-based Linux distributions.* + If the package has not yet been promoted to your Ubuntu/Debian installation, or you want the most recent release of `bat`, download the latest `.deb` package from the [release page](https://github.com/sharkdp/bat/releases) and install it via: ```bash -sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux diff --git a/assets/syntaxes.bin b/assets/syntaxes.bin index 2931fdda..a5a81ced 100644 Binary files a/assets/syntaxes.bin and b/assets/syntaxes.bin differ diff --git a/assets/syntaxes/02_Extra/Elixir b/assets/syntaxes/02_Extra/Elixir index 89b3bada..1f010d5f 160000 --- a/assets/syntaxes/02_Extra/Elixir +++ b/assets/syntaxes/02_Extra/Elixir @@ -1 +1 @@ -Subproject commit 89b3bada3262bc58e0a5393d12a82f725d5063ad +Subproject commit 1f010d5f63f20aa8eafa57aaaeafe736e0748dca diff --git a/assets/syntaxes/02_Extra/Elm b/assets/syntaxes/02_Extra/Elm index dfbb8bdc..e266d279 160000 --- a/assets/syntaxes/02_Extra/Elm +++ b/assets/syntaxes/02_Extra/Elm @@ -1 +1 @@ -Subproject commit dfbb8bdc9a8403092c884d3eb893a270538cfa72 +Subproject commit e266d279c8074aa342f106554cfa87ebe839a782 diff --git a/assets/syntaxes/02_Extra/Email b/assets/syntaxes/02_Extra/Email index fc034fb8..ee3e68fc 160000 --- a/assets/syntaxes/02_Extra/Email +++ b/assets/syntaxes/02_Extra/Email @@ -1 +1 @@ -Subproject commit fc034fb85ae8a277627f1148769924dbc115dbe4 +Subproject commit ee3e68fce26cb7ab6ad8c8bf7ca45cfe2a70c07a diff --git a/assets/syntaxes/02_Extra/Julia b/assets/syntaxes/02_Extra/Julia index 0ca4cc29..6c0d770f 160000 --- a/assets/syntaxes/02_Extra/Julia +++ b/assets/syntaxes/02_Extra/Julia @@ -1 +1 @@ -Subproject commit 0ca4cc29907e9476cb603fed00d1d5fd9dc13c9c +Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95 diff --git a/assets/syntaxes/02_Extra/ssh-config b/assets/syntaxes/02_Extra/ssh-config index 16e19d5d..3ec06d0e 160000 --- a/assets/syntaxes/02_Extra/ssh-config +++ b/assets/syntaxes/02_Extra/ssh-config @@ -1 +1 @@ -Subproject commit 16e19d5da48a7c4d30fdded8ac4c97ff643f5d7b +Subproject commit 3ec06d0e9c2d20e7bb31f0149364d25f77503d97 diff --git a/assets/themes.bin b/assets/themes.bin index 54c752f9..9de98391 100644 Binary files a/assets/themes.bin and b/assets/themes.bin differ diff --git a/assets/themes/Solarized b/assets/themes/Solarized index 87e01090..3707f68d 160000 --- a/assets/themes/Solarized +++ b/assets/themes/Solarized @@ -1 +1 @@ -Subproject commit 87e01090cf5fb821a234265b3138426ae84900e7 +Subproject commit 3707f68ddc535723c02c65cbc97187c1aa99ad4d diff --git a/assets/themes/dracula-sublime b/assets/themes/dracula-sublime index 811a6344..26c57ec2 160000 --- a/assets/themes/dracula-sublime +++ b/assets/themes/dracula-sublime @@ -1 +1 @@ -Subproject commit 811a634420a0cb9023bb7afd1c8968a5aaf6a753 +Subproject commit 26c57ec282abcaa76e57e055f38432bd827ac34e diff --git a/assets/themes/onehalf b/assets/themes/onehalf index fdcbffe3..970abdf2 160000 --- a/assets/themes/onehalf +++ b/assets/themes/onehalf @@ -1 +1 @@ -Subproject commit fdcbffe3175c29bb78d19dcaf9b2a456482fcf1e +Subproject commit 970abdf26b399100cbb59c6b6e693c4ff877c59d diff --git a/doc/README-ja.md b/doc/README-ja.md index 3733675e..0afb08bc 100644 --- a/doc/README-ja.md +++ b/doc/README-ja.md @@ -180,7 +180,7 @@ apt install bat batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、 次の方法でインストールします: ```bash -sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux diff --git a/doc/README-ko.md b/doc/README-ko.md index bd451b78..4d116086 100644 --- a/doc/README-ko.md +++ b/doc/README-ko.md @@ -170,7 +170,7 @@ apt install bat 만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다: ```bash -sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture +sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture ``` ### On Alpine Linux diff --git a/src/controller.rs b/src/controller.rs index 87286092..a7f2f3c0 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -75,7 +75,7 @@ impl<'b> Controller<'b> { } }; - for input in inputs.into_iter() { + for (index, input) in inputs.into_iter().enumerate() { match input.open(io::stdin().lock()) { Err(error) => { print_error(&error, writer); @@ -128,6 +128,7 @@ impl<'b> Controller<'b> { &mut *printer, writer, &mut opened_input, + index != 0, #[cfg(feature = "git")] &line_changes, ); @@ -148,10 +149,11 @@ impl<'b> Controller<'b> { printer: &mut dyn Printer, writer: &mut dyn Write, input: &mut OpenedInput, + add_header_padding: bool, #[cfg(feature = "git")] line_changes: &Option, ) -> Result<()> { if !input.reader.first_line.is_empty() || self.config.style_components.header() { - printer.print_header(writer, input)?; + printer.print_header(writer, input, add_header_padding)?; } if !input.reader.first_line.is_empty() { diff --git a/src/printer.rs b/src/printer.rs index bddf6d89..cfc9d1af 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -33,7 +33,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::wrapping::WrappingMode; pub(crate) trait Printer { - fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>; + fn print_header( + &mut self, + handle: &mut dyn Write, + input: &OpenedInput, + add_header_padding: bool, + ) -> Result<()>; fn print_footer(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>; fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>; @@ -56,7 +61,12 @@ impl SimplePrinter { } impl Printer for SimplePrinter { - fn print_header(&mut self, _handle: &mut dyn Write, _input: &OpenedInput) -> Result<()> { + fn print_header( + &mut self, + _handle: &mut dyn Write, + _input: &OpenedInput, + _add_header_padding: bool, + ) -> Result<()> { Ok(()) } @@ -219,7 +229,12 @@ impl<'a> InteractivePrinter<'a> { } impl<'a> Printer for InteractivePrinter<'a> { - fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()> { + fn print_header( + &mut self, + handle: &mut dyn Write, + input: &OpenedInput, + add_header_padding: bool, + ) -> Result<()> { if !self.config.style_components.header() { if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable { writeln!( @@ -248,6 +263,9 @@ impl<'a> Printer for InteractivePrinter<'a> { .paint(if self.panel_width > 0 { "│ " } else { "" }), )?; } else { + if add_header_padding { + writeln!(handle)?; + } write!(handle, "{}", " ".repeat(self.panel_width))?; } diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 36954b3d..cd6cde5b 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -615,7 +615,7 @@ fn filename_multiple_ok() { .arg("--file-name=bar") .assert() .success() - .stdout("File: foo\nFile: bar\n") + .stdout("File: foo\n\nFile: bar\n") .stderr(""); } @@ -632,6 +632,18 @@ fn filename_multiple_err() { .failure(); } +#[test] +fn header_padding() { + bat() + .arg("--decorations=always") + .arg("--style=header") + .arg("test.txt") + .arg("single-line.txt") + .assert() + .stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n") + .stderr(""); +} + #[cfg(target_os = "linux")] #[test] fn file_with_invalid_utf8_filename() {