mirror of https://github.com/sharkdp/bat.git
Compare commits
21 Commits
1e83c1becc
...
8d8c6bd691
Author | SHA1 | Date |
---|---|---|
John DeBoard | 8d8c6bd691 | |
Stéphane Blondon | bb4d1cbd2e | |
Stéphane Blondon | 23ec433167 | |
Sharun | 9eaed3e3f0 | |
sblondon | d5bd4aa93f | |
John DeBoard | b05cde7ab4 | |
deboard | 2a29029828 | |
deboard | ac4f4b40df | |
John DeBoard | b1819cb09d | |
deboard | 10fd0b70e5 | |
deboard | ed6aad7835 | |
John DeBoard | e5858e27d9 | |
deboard | 1f3e3e0d71 | |
deboard | 635175ea64 | |
deboard | 7ae3185f47 | |
deboard | cb2f8f8210 | |
deboard | 76a655da5f | |
deboard | 6a0f6beab6 | |
deboard | 6b90c21ba3 | |
deboard | 6ea3ac71d7 | |
deboard | 54cec4a8e0 |
|
@ -6,10 +6,14 @@
|
||||||
- `bat --squeeze-blank`/`bat -s` will now squeeze consecutive empty lines, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
- `bat --squeeze-blank`/`bat -s` will now squeeze consecutive empty lines, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
||||||
- `bat --squeeze-limit` to set the maximum number of empty consecutive when using `--squeeze-blank`, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
- `bat --squeeze-limit` to set the maximum number of empty consecutive when using `--squeeze-blank`, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
||||||
- `PrettyPrinter::squeeze_empty_lines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
- `PrettyPrinter::squeeze_empty_lines` to support line squeezing for bat as a library, see #1441 (@eth-p) and #2665 (@einfachIrgendwer0815)
|
||||||
|
- Syntax highlighting for JavaScript files that start with `#!/usr/bin/env bun` #2913 (@sharunkumar)
|
||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
|
||||||
|
- Send all bat error messages to stderr, see #2827 (@deboard)
|
||||||
|
|
||||||
- Fix long file name wrapping in header, see #2835 (@FilipRazek)
|
- Fix long file name wrapping in header, see #2835 (@FilipRazek)
|
||||||
|
-
|
||||||
- Fix `NO_COLOR` support, see #2767 (@acuteenvy)
|
- Fix `NO_COLOR` support, see #2767 (@acuteenvy)
|
||||||
- Fix handling of inputs with OSC ANSI escape sequences, see #2541 and #2544 (@eth-p)
|
- Fix handling of inputs with OSC ANSI escape sequences, see #2541 and #2544 (@eth-p)
|
||||||
- Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p)
|
- Fix handling of inputs with combined ANSI color and attribute sequences, see #2185 and #2856 (@eth-p)
|
||||||
|
@ -33,6 +37,8 @@
|
||||||
- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon)
|
- Relax syntax mapping rule restrictions to allow brace expansion #2865 (@cyqsimon)
|
||||||
- Apply clippy fixes #2864 (@cyqsimon)
|
- Apply clippy fixes #2864 (@cyqsimon)
|
||||||
- Faster startup by offloading glob matcher building to a worker thread #2868 (@cyqsimon)
|
- Faster startup by offloading glob matcher building to a worker thread #2868 (@cyqsimon)
|
||||||
|
- Display which theme is the default one in basic output (no colors), see #2937 (@sblondon)
|
||||||
|
- Display which theme is the default one in colored output, see #2838 (@sblondon)
|
||||||
|
|
||||||
## Syntaxes
|
## Syntaxes
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
Submodule assets/syntaxes/01_Packages contains modified content
|
||||||
|
diff --git syntaxes/01_Packages/JavaScript/JavaScript.sublime-syntax syntaxes/01_Packages/JavaScript/JavaScript.sublime-syntax
|
||||||
|
index 05a4fed6..78a7bf55 100644
|
||||||
|
--- syntaxes/01_Packages/JavaScript/JavaScript.sublime-syntax
|
||||||
|
+++ syntaxes/01_Packages/JavaScript/JavaScript.sublime-syntax
|
||||||
|
@@ -5,7 +5,7 @@ name: JavaScript
|
||||||
|
file_extensions:
|
||||||
|
- js
|
||||||
|
- htc
|
||||||
|
-first_line_match: ^#!\s*/.*\b(node|js)\b
|
||||||
|
+first_line_match: ^#!\s*/.*\b(node|bun|js)\b
|
||||||
|
scope: source.js
|
||||||
|
variables:
|
||||||
|
bin_digit: '[01_]'
|
|
@ -30,6 +30,7 @@ use directories::PROJECT_DIRS;
|
||||||
use globset::GlobMatcher;
|
use globset::GlobMatcher;
|
||||||
|
|
||||||
use bat::{
|
use bat::{
|
||||||
|
assets::HighlightingAssets,
|
||||||
config::Config,
|
config::Config,
|
||||||
controller::Controller,
|
controller::Controller,
|
||||||
error::*,
|
error::*,
|
||||||
|
@ -199,19 +200,31 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
||||||
let stdout = io::stdout();
|
let stdout = io::stdout();
|
||||||
let mut stdout = stdout.lock();
|
let mut stdout = stdout.lock();
|
||||||
|
|
||||||
if config.colored_output {
|
let default_theme = HighlightingAssets::default_theme();
|
||||||
for theme in assets.themes() {
|
for theme in assets.themes() {
|
||||||
|
let default_theme_info = if default_theme == theme {
|
||||||
|
" (default)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
if config.colored_output {
|
||||||
writeln!(
|
writeln!(
|
||||||
stdout,
|
stdout,
|
||||||
"Theme: {}\n",
|
"Theme: {}{}\n",
|
||||||
Style::new().bold().paint(theme.to_string())
|
Style::new().bold().paint(theme.to_string()),
|
||||||
|
default_theme_info
|
||||||
)?;
|
)?;
|
||||||
config.theme = theme.to_string();
|
config.theme = theme.to_string();
|
||||||
Controller::new(&config, &assets)
|
Controller::new(&config, &assets)
|
||||||
.run(vec![theme_preview_file()], None)
|
.run(vec![theme_preview_file()], None)
|
||||||
.ok();
|
.ok();
|
||||||
writeln!(stdout)?;
|
writeln!(stdout)?;
|
||||||
|
} else {
|
||||||
|
writeln!(stdout, "{theme}{default_theme_info}")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.colored_output {
|
||||||
writeln!(
|
writeln!(
|
||||||
stdout,
|
stdout,
|
||||||
"Further themes can be installed to '{}', \
|
"Further themes can be installed to '{}', \
|
||||||
|
@ -220,10 +233,6 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
|
||||||
https://github.com/sharkdp/bat#adding-new-themes",
|
https://github.com/sharkdp/bat#adding-new-themes",
|
||||||
config_dir.join("themes").to_string_lossy()
|
config_dir.join("themes").to_string_lossy()
|
||||||
)?;
|
)?;
|
||||||
} else {
|
|
||||||
for theme in assets.themes() {
|
|
||||||
writeln!(stdout, "{theme}")?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
10
src/error.rs
10
src/error.rs
|
@ -67,7 +67,15 @@ pub fn default_error_handler(error: &Error, output: &mut dyn Write) {
|
||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
writeln!(output, "{}: {}", Red.paint("[bat error]"), error).ok();
|
// default - always write [bat error] to stderr
|
||||||
|
let stderr = std::io::stderr();
|
||||||
|
writeln!(
|
||||||
|
&mut stderr.lock(),
|
||||||
|
"{}: {}",
|
||||||
|
Red.paint("[bat error]"),
|
||||||
|
error
|
||||||
|
)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -272,6 +272,41 @@ fn squeeze_limit_line_numbers() {
|
||||||
.stdout(" 1 line 1\n 2 \n 3 \n 4 \n 5 line 5\n 6 \n 7 \n 8 \n 9 \n 10 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 29 \n 30 line 30\n");
|
.stdout(" 1 line 1\n 2 \n 3 \n 4 \n 5 line 5\n 6 \n 7 \n 8 \n 9 \n 10 \n 20 line 20\n 21 line 21\n 22 \n 23 \n 24 line 24\n 25 \n 26 line 26\n 27 \n 28 \n 29 \n 30 line 30\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn list_themes_with_colors() {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let default_theme_chunk = "Monokai Extended Light\x1B[0m (default)";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let default_theme_chunk = "Monokai Extended\x1B[0m (default)";
|
||||||
|
|
||||||
|
bat()
|
||||||
|
.arg("--color=always")
|
||||||
|
.arg("--list-themes")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("DarkNeon").normalize())
|
||||||
|
.stdout(predicate::str::contains(default_theme_chunk).normalize())
|
||||||
|
.stdout(predicate::str::contains("Output the square of a number.").normalize());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn list_themes_without_colors() {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
let default_theme_chunk = "Monokai Extended Light (default)";
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "macos"))]
|
||||||
|
let default_theme_chunk = "Monokai Extended (default)";
|
||||||
|
|
||||||
|
bat()
|
||||||
|
.arg("--color=never")
|
||||||
|
.arg("--list-themes")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout(predicate::str::contains("DarkNeon").normalize())
|
||||||
|
.stdout(predicate::str::contains(default_theme_chunk).normalize());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
|
#[cfg_attr(any(not(feature = "git"), target_os = "windows"), ignore)]
|
||||||
fn short_help() {
|
fn short_help() {
|
||||||
|
@ -812,6 +847,16 @@ fn env_var_bat_pager_value_bat() {
|
||||||
.stderr(predicate::str::contains("bat as a pager is disallowed"));
|
.stderr(predicate::str::contains("bat as a pager is disallowed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn bat_error_to_stderr() {
|
||||||
|
bat()
|
||||||
|
.env("BAT_PAGER", "bat")
|
||||||
|
.arg("/tmp")
|
||||||
|
.assert()
|
||||||
|
.failure()
|
||||||
|
.stderr(predicate::str::contains("[bat error]"));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pager_value_bat() {
|
fn pager_value_bat() {
|
||||||
bat()
|
bat()
|
||||||
|
@ -1284,6 +1329,9 @@ fn can_print_file_starting_with_cache() {
|
||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn send_all_bat_error_to_stderr() {}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn does_not_print_unwanted_file_named_cache() {
|
fn does_not_print_unwanted_file_named_cache() {
|
||||||
bat_with_config().arg("cach").assert().failure();
|
bat_with_config().arg("cach").assert().failure();
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## test for issue 2561
|
||||||
|
|
||||||
|
OUTPUT=$(mktemp)
|
||||||
|
BAT=bat
|
||||||
|
code=$($BAT /tmp 2> $OUTPUT; cat $OUTPUT | grep error; echo $?)
|
||||||
|
|
||||||
|
if [[ $code == 1 ]]; then
|
||||||
|
echo "stderr test fsil"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue