mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-23 22:19:08 +01:00
Merge branch 'master' of github.com:sharkdp/bat into string-input
This commit is contained in:
commit
b8687bc969
@ -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
2
Cargo.lock
generated
@ -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)",
|
||||||
|
@ -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/*",
|
||||||
|
14
README.md
14
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)
|
[![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
BIN
assets/syntaxes.bin
vendored
Binary file not shown.
2
assets/syntaxes/02_Extra/Elixir
vendored
2
assets/syntaxes/02_Extra/Elixir
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 89b3bada3262bc58e0a5393d12a82f725d5063ad
|
Subproject commit 1f010d5f63f20aa8eafa57aaaeafe736e0748dca
|
2
assets/syntaxes/02_Extra/Elm
vendored
2
assets/syntaxes/02_Extra/Elm
vendored
@ -1 +1 @@
|
|||||||
Subproject commit dfbb8bdc9a8403092c884d3eb893a270538cfa72
|
Subproject commit e266d279c8074aa342f106554cfa87ebe839a782
|
2
assets/syntaxes/02_Extra/Email
vendored
2
assets/syntaxes/02_Extra/Email
vendored
@ -1 +1 @@
|
|||||||
Subproject commit fc034fb85ae8a277627f1148769924dbc115dbe4
|
Subproject commit ee3e68fce26cb7ab6ad8c8bf7ca45cfe2a70c07a
|
2
assets/syntaxes/02_Extra/Julia
vendored
2
assets/syntaxes/02_Extra/Julia
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 0ca4cc29907e9476cb603fed00d1d5fd9dc13c9c
|
Subproject commit 6c0d770fc74e6bc037c70cae1f94fe113b60fd95
|
2
assets/syntaxes/02_Extra/ssh-config
vendored
2
assets/syntaxes/02_Extra/ssh-config
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 16e19d5da48a7c4d30fdded8ac4c97ff643f5d7b
|
Subproject commit 3ec06d0e9c2d20e7bb31f0149364d25f77503d97
|
BIN
assets/themes.bin
vendored
BIN
assets/themes.bin
vendored
Binary file not shown.
2
assets/themes/Solarized
vendored
2
assets/themes/Solarized
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 87e01090cf5fb821a234265b3138426ae84900e7
|
Subproject commit 3707f68ddc535723c02c65cbc97187c1aa99ad4d
|
2
assets/themes/dracula-sublime
vendored
2
assets/themes/dracula-sublime
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 811a634420a0cb9023bb7afd1c8968a5aaf6a753
|
Subproject commit 26c57ec282abcaa76e57e055f38432bd827ac34e
|
2
assets/themes/onehalf
vendored
2
assets/themes/onehalf
vendored
@ -1 +1 @@
|
|||||||
Subproject commit fdcbffe3175c29bb78d19dcaf9b2a456482fcf1e
|
Subproject commit 970abdf26b399100cbb59c6b6e693c4ff877c59d
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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() {
|
||||||
|
@ -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))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user