on master help sign in
Merge branch 'master' of github.com:sharkdp/bat into string-input
commitb8687bc9695027b967bdbae906f63b291f626525 authorEthan P <eth-p+git@hidden.email> dateFri 15 May 2020, 13:22 (6 years ago) parent9166c9dc2c7070
19 files changed+68−20
CHANGELOG.md+6 Cargo.lock+1−1 Cargo.toml+1−1 README.md+12−2 assets/syntaxes.bin assets/syntaxes/02_Extra/Elixir+1−1 assets/syntaxes/02_Extra/Elm+1−1 assets/syntaxes/02_Extra/Email+1−1 assets/syntaxes/02_Extra/Julia+1−1 assets/syntaxes/02_Extra/ssh-config+1−1 assets/themes.bin assets/themes/Solarized+1−1 assets/themes/dracula-sublime+1−1 assets/themes/onehalf+1−1 doc/README-ja.md+1−1 doc/README-ko.md+1−1 src/controller.rs+4−2 src/printer.rs+21−3 tests/integration_tests.rs+13−1
CHANGELOG.md+6
@@ -1,7 +1,13 @@
11# unreleased
22
33## Features
4+
5+- Add padding above headers when not using a grid, see #968 and #981 (@pt2121)
6+
47## Bugfixes
8+
9+- bat mishighlights Users that start with digits in SSH config, see #984
10+
511## Other
612## New syntaxes
713## New themes
Cargo.lock+1−1
@@ -114,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
114114
115115[[package]]
116116name = "bat"
117−version = "0.15.0"
117+version = "0.15.1"
118118dependencies = [
119119 "ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
120120 "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
Cargo.toml+1−1
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
77name = "bat"
88readme = "README.md"
99repository = "https://github.com/sharkdp/bat"
10−version = "0.15.0"
10+version = "0.15.1"
1111exclude = [
1212 "assets/syntaxes/*",
1313 "assets/themes/*",
README.md+12−2
@@ -168,7 +168,7 @@ The [`prettybat`](https://github.com/eth-p/bat-extras/blob/master/doc/prettybat.
168168
169169[![Packaging status](https://repology.org/badge/vertical-allrepos/bat.svg)](https://repology.org/project/bat/versions)
170170
171−### On Ubuntu
171+### On Ubuntu (using `apt`)
172172*... and other Debian-based Linux distributions.*
173173
174174`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:
182182apt install bat
183183```
184184
185+If you install `bat` this way, please note that the executable may be installed as `batcat` instead of `bat` (due to [a name
186+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:
187+``` bash
188+mkdir -p ~/.local/bin
189+ln -s /usr/bin/batcat ~/.local/bin/bat
190+```
191+
192+### On Ubuntu (using most recent `.deb` packages)
193+*... and other Debian-based Linux distributions.*
194+
185195If the package has not yet been promoted to your Ubuntu/Debian installation, or you want
186196the most recent release of `bat`, download the latest `.deb` package from the
187197[release page](https://github.com/sharkdp/bat/releases) and install it via:
188198
189199```bash
190−sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
200+sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
191201```
192202
193203### On Alpine Linux
assets/syntaxes.bin

Binary file not shown.

assets/syntaxes/02_Extra/Elixir+1−1

Submodule changed.

assets/syntaxes/02_Extra/Elm+1−1

Submodule changed.

assets/syntaxes/02_Extra/Email+1−1

Submodule changed.

assets/syntaxes/02_Extra/Julia+1−1

Submodule changed.

assets/syntaxes/02_Extra/ssh-config+1−1

Submodule changed.

assets/themes.bin

Binary file not shown.

assets/themes/Solarized+1−1

Submodule changed.

assets/themes/dracula-sublime+1−1

Submodule changed.

assets/themes/onehalf+1−1

Submodule changed.

doc/README-ja.md+1−1
@@ -180,7 +180,7 @@ apt install bat
180180batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
181181次の方法でインストールします:
182182```bash
183−sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
183+sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
184184```
185185
186186### On Alpine Linux
doc/README-ko.md+1−1
@@ -170,7 +170,7 @@ apt install bat
170170만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
171171
172172```bash
173−sudo dpkg -i bat_0.15.0_amd64.deb # adapt version number and architecture
173+sudo dpkg -i bat_0.15.1_amd64.deb # adapt version number and architecture
174174```
175175
176176### On Alpine Linux
src/controller.rs+4−2
@@ -75,7 +75,7 @@ impl<'b> Controller<'b> {
7575 }
7676 };
7777
78− for input in inputs.into_iter() {
78+ for (index, input) in inputs.into_iter().enumerate() {
7979 match input.open(io::stdin().lock()) {
8080 Err(error) => {
8181 print_error(&error, writer);
@@ -128,6 +128,7 @@ impl<'b> Controller<'b> {
128128 &mut *printer,
129129 writer,
130130 &mut opened_input,
131+ index != 0,
131132 #[cfg(feature = "git")]
132133 &line_changes,
133134 );
@@ -148,10 +149,11 @@ impl<'b> Controller<'b> {
148149 printer: &mut dyn Printer,
149150 writer: &mut dyn Write,
150151 input: &mut OpenedInput,
152+ add_header_padding: bool,
151153 #[cfg(feature = "git")] line_changes: &Option<LineChanges>,
152154 ) -> Result<()> {
153155 if !input.reader.first_line.is_empty() || self.config.style_components.header() {
154− printer.print_header(writer, input)?;
156+ printer.print_header(writer, input, add_header_padding)?;
155157 }
156158
157159 if !input.reader.first_line.is_empty() {
src/printer.rs+21−3
@@ -33,7 +33,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
3333use crate::wrapping::WrappingMode;
3434
3535pub(crate) trait Printer {
36− fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>;
36+ fn print_header(
37+ &mut self,
38+ handle: &mut dyn Write,
39+ input: &OpenedInput,
40+ add_header_padding: bool,
41+ ) -> Result<()>;
3742 fn print_footer(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>;
3843
3944 fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
@@ -56,7 +61,12 @@ impl SimplePrinter {
5661}
5762
5863impl Printer for SimplePrinter {
59− fn print_header(&mut self, _handle: &mut dyn Write, _input: &OpenedInput) -> Result<()> {
64+ fn print_header(
65+ &mut self,
66+ _handle: &mut dyn Write,
67+ _input: &OpenedInput,
68+ _add_header_padding: bool,
69+ ) -> Result<()> {
6070 Ok(())
6171 }
6272
@@ -219,7 +229,12 @@ impl<'a> InteractivePrinter<'a> {
219229}
220230
221231impl<'a> Printer for InteractivePrinter<'a> {
222− fn print_header(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()> {
232+ fn print_header(
233+ &mut self,
234+ handle: &mut dyn Write,
235+ input: &OpenedInput,
236+ add_header_padding: bool,
237+ ) -> Result<()> {
223238 if !self.config.style_components.header() {
224239 if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
225240 writeln!(
@@ -248,6 +263,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
248263 .paint(if self.panel_width > 0 { "│ " } else { "" }),
249264 )?;
250265 } else {
266+ if add_header_padding {
267+ writeln!(handle)?;
268+ }
251269 write!(handle, "{}", " ".repeat(self.panel_width))?;
252270 }
253271
tests/integration_tests.rs+13−1
@@ -615,7 +615,7 @@ fn filename_multiple_ok() {
615615 .arg("--file-name=bar")
616616 .assert()
617617 .success()
618− .stdout("File: foo\nFile: bar\n")
618+ .stdout("File: foo\n\nFile: bar\n")
619619 .stderr("");
620620}
621621
@@ -632,6 +632,18 @@ fn filename_multiple_err() {
632632 .failure();
633633}
634634
635+#[test]
636+fn header_padding() {
637+ bat()
638+ .arg("--decorations=always")
639+ .arg("--style=header")
640+ .arg("test.txt")
641+ .arg("single-line.txt")
642+ .assert()
643+ .stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n")
644+ .stderr("");
645+}
646+
635647#[cfg(target_os = "linux")]
636648#[test]
637649fn file_with_invalid_utf8_filename() {