1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-02 03:12:25 +01:00

Merge branch 'master' of github.com:sharkdp/bat into string-input

This commit is contained in:
Ethan P
2020-05-15 13:22:24 -07:00
19 changed files with 68 additions and 20 deletions

View File

@@ -1,7 +1,13 @@
# unreleased # unreleased
## Features ## Features
- Add padding above headers when not using a grid, see #968 and #981 (@pt2121)
## Bugfixes ## Bugfixes
- bat mishighlights Users that start with digits in SSH config, see #984
## Other ## Other
## New syntaxes ## New syntaxes
## New themes ## New themes

2
Cargo.lock generated
View File

@@ -114,7 +114,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "bat" name = "bat"
version = "0.15.0" version = "0.15.1"
dependencies = [ dependencies = [
"ansi_colours 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "ansi_term 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
name = "bat" name = "bat"
readme = "README.md" readme = "README.md"
repository = "https://github.com/sharkdp/bat" repository = "https://github.com/sharkdp/bat"
version = "0.15.0" version = "0.15.1"
exclude = [ exclude = [
"assets/syntaxes/*", "assets/syntaxes/*",
"assets/themes/*", "assets/themes/*",

View File

@@ -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) [![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.* *... and other Debian-based Linux distributions.*
`bat` is making its way through the [Ubuntu](https://packages.ubuntu.com/eoan/bat) and `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 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 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 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: [release page](https://github.com/sharkdp/bat/releases) and install it via:
```bash ```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 ### On Alpine Linux

BIN
assets/syntaxes.bin vendored

Binary file not shown.

BIN
assets/themes.bin vendored

Binary file not shown.

View File

@@ -180,7 +180,7 @@ apt install bat
batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、 batの最新リリースを実行する場合、または Ubuntu/Debian の古いバージョンを使用している場合は、[release page](https://github.com/sharkdp/bat/releases) から最新の `.deb` パッケージをダウンロードし、
次の方法でインストールします: 次の方法でインストールします:
```bash ```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 ### On Alpine Linux

View File

@@ -170,7 +170,7 @@ apt install bat
만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다: 만약 최근 릴리즈된 bat을 사용을 원하거나 buntu/Debian 예전 버전을 사용하는 경우, [릴리즈 페이지](https://github.com/sharkdp/bat/releases)에서 다음과 같이 `.deb` 패키지를 받아 설치 할 수도 있습니다:
```bash ```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 ### On Alpine Linux

View File

@@ -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()) { match input.open(io::stdin().lock()) {
Err(error) => { Err(error) => {
print_error(&error, writer); print_error(&error, writer);
@@ -128,6 +128,7 @@ impl<'b> Controller<'b> {
&mut *printer, &mut *printer,
writer, writer,
&mut opened_input, &mut opened_input,
index != 0,
#[cfg(feature = "git")] #[cfg(feature = "git")]
&line_changes, &line_changes,
); );
@@ -148,10 +149,11 @@ impl<'b> Controller<'b> {
printer: &mut dyn Printer, printer: &mut dyn Printer,
writer: &mut dyn Write, writer: &mut dyn Write,
input: &mut OpenedInput, input: &mut OpenedInput,
add_header_padding: bool,
#[cfg(feature = "git")] line_changes: &Option<LineChanges>, #[cfg(feature = "git")] line_changes: &Option<LineChanges>,
) -> Result<()> { ) -> Result<()> {
if !input.reader.first_line.is_empty() || self.config.style_components.header() { 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() { if !input.reader.first_line.is_empty() {

View File

@@ -33,7 +33,12 @@ use crate::terminal::{as_terminal_escaped, to_ansi_color};
use crate::wrapping::WrappingMode; use crate::wrapping::WrappingMode;
pub(crate) trait Printer { 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_footer(&mut self, handle: &mut dyn Write, input: &OpenedInput) -> Result<()>;
fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>; fn print_snip(&mut self, handle: &mut dyn Write) -> Result<()>;
@@ -56,7 +61,12 @@ impl SimplePrinter {
} }
impl Printer for 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(()) Ok(())
} }
@@ -219,7 +229,12 @@ impl<'a> InteractivePrinter<'a> {
} }
impl<'a> Printer for 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 !self.config.style_components.header() {
if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable { if Some(ContentType::BINARY) == self.content_type && !self.config.show_nonprintable {
writeln!( writeln!(
@@ -248,6 +263,9 @@ impl<'a> Printer for InteractivePrinter<'a> {
.paint(if self.panel_width > 0 { "" } else { "" }), .paint(if self.panel_width > 0 { "" } else { "" }),
)?; )?;
} else { } else {
if add_header_padding {
writeln!(handle)?;
}
write!(handle, "{}", " ".repeat(self.panel_width))?; write!(handle, "{}", " ".repeat(self.panel_width))?;
} }

View File

@@ -615,7 +615,7 @@ fn filename_multiple_ok() {
.arg("--file-name=bar") .arg("--file-name=bar")
.assert() .assert()
.success() .success()
.stdout("File: foo\nFile: bar\n") .stdout("File: foo\n\nFile: bar\n")
.stderr(""); .stderr("");
} }
@@ -632,6 +632,18 @@ fn filename_multiple_err() {
.failure(); .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")] #[cfg(target_os = "linux")]
#[test] #[test]
fn file_with_invalid_utf8_filename() { fn file_with_invalid_utf8_filename() {