1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-11-01 07:32:01 +00:00

Compare commits

..

21 Commits

Author SHA1 Message Date
auto-merge-dependabot-prs[bot]
490e1580ad Merge pull request #3471 from sharkdp/dependabot/cargo/serde_with-3.15.1
build(deps): bump serde_with from 3.12.0 to 3.15.1
2025-11-01 05:15:10 +00:00
dependabot[bot]
cbfbfc8ff3 build(deps): bump serde_with from 3.12.0 to 3.15.1
Bumps [serde_with](https://github.com/jonasbb/serde_with) from 3.12.0 to 3.15.1.
- [Release notes](https://github.com/jonasbb/serde_with/releases)
- [Commits](https://github.com/jonasbb/serde_with/compare/v3.12.0...v3.15.1)

---
updated-dependencies:
- dependency-name: serde_with
  dependency-version: 3.15.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 05:03:16 +00:00
auto-merge-dependabot-prs[bot]
b6edf7ab0b Merge pull request #3468 from sharkdp/dependabot/cargo/prettyplease-0.2.37
build(deps): bump prettyplease from 0.2.35 to 0.2.37
2025-11-01 05:00:21 +00:00
dependabot[bot]
65e6b4de69 build(deps): bump prettyplease from 0.2.35 to 0.2.37
Bumps [prettyplease](https://github.com/dtolnay/prettyplease) from 0.2.35 to 0.2.37.
- [Release notes](https://github.com/dtolnay/prettyplease/releases)
- [Commits](https://github.com/dtolnay/prettyplease/compare/0.2.35...0.2.37)

---
updated-dependencies:
- dependency-name: prettyplease
  dependency-version: 0.2.37
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 04:42:58 +00:00
auto-merge-dependabot-prs[bot]
2ca62e25f1 Merge pull request #3474 from sharkdp/dependabot/cargo/git2-0.20.2
build(deps): bump git2 from 0.20.0 to 0.20.2
2025-11-01 04:39:53 +00:00
dependabot[bot]
1b2a814478 build(deps): bump git2 from 0.20.0 to 0.20.2
Bumps [git2](https://github.com/rust-lang/git2-rs) from 0.20.0 to 0.20.2.
- [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/git2-rs/compare/git2-0.20.0...git2-0.20.2)

---
updated-dependencies:
- dependency-name: git2
  dependency-version: 0.20.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 04:22:33 +00:00
auto-merge-dependabot-prs[bot]
e33967aa39 Merge pull request #3467 from sharkdp/dependabot/cargo/regex-1.12.2
build(deps): bump regex from 1.11.1 to 1.12.2
2025-11-01 04:17:04 +00:00
dependabot[bot]
a1adefce36 build(deps): bump regex from 1.11.1 to 1.12.2
Bumps [regex](https://github.com/rust-lang/regex) from 1.11.1 to 1.12.2.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.11.1...1.12.2)

---
updated-dependencies:
- dependency-name: regex
  dependency-version: 1.12.2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 03:40:47 +00:00
auto-merge-dependabot-prs[bot]
6e87e02e96 Merge pull request #3465 from sharkdp/dependabot/cargo/terminal-colorsaurus-1.0.1
build(deps): bump terminal-colorsaurus from 1.0.0 to 1.0.1
2025-11-01 03:37:12 +00:00
dependabot[bot]
ab9cc674d5 build(deps): bump terminal-colorsaurus from 1.0.0 to 1.0.1
Bumps [terminal-colorsaurus](https://github.com/bash/terminal-colorsaurus) from 1.0.0 to 1.0.1.
- [Release notes](https://github.com/bash/terminal-colorsaurus/releases)
- [Changelog](https://github.com/bash/terminal-colorsaurus/blob/main/changelog.md)
- [Commits](https://github.com/bash/terminal-colorsaurus/compare/1.0.0...1.0.1)

---
updated-dependencies:
- dependency-name: terminal-colorsaurus
  dependency-version: 1.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-01 03:02:09 +00:00
Jack Haden-Enneking
5371426588 alternatives.md: fix emoji & formatting
Could replace all emoji shortcodes (`✔️` & ``) in source with actual emoji. Erred on the side of least change.
2025-10-31 19:32:29 +01:00
Justin Su
4e13c3eb5b Update CHANGELOG.md
Also fix a typo from the previous release
2025-10-20 19:23:26 +02:00
Justin Su
7e55608975 docs: Clarify that -X/--no-init is not added on modern versions of less 2025-10-20 19:23:26 +02:00
Justin Su
4bd5cbca8e docs: Mention less options by short+long names 2025-10-20 19:23:26 +02:00
Keith Hall
7c3fa7e1ce Merge pull request #3448 from akinomyoga/bash-fullquote
Use `-o fullquote` and `-o noquote` for more robust escaping in Bash completions
2025-10-20 19:55:56 +03:00
Koichi Murase
3188a147d8 Use "-o fullquote" and "-o noquote" to escape Bash completions 2025-10-20 19:38:54 +09:00
Koichi Murase
926fbc4b13 Fix indentation of the Bash completion file 2025-10-20 17:59:48 +09:00
Keith Hall
006d77fa39 Merge pull request #3442 from lmmx/patch-1
fix: allow hyphen values to `-r`/`--line-range`
2025-10-19 23:44:25 +03:00
Louis Maddox
52a792d46f fix: allow hyphen values to -r/--line-range
via #2944
2025-10-19 21:24:59 +01:00
Keith Hall
20db989fb1 Merge pull request #3441 from sharkdp/prepare_changelog
Prepare changelog for future changes
2025-10-19 21:40:50 +03:00
Keith Hall
2c63d3c792 Prepare changelog for future changes 2025-10-19 21:24:54 +03:00
9 changed files with 140 additions and 65 deletions

View File

@@ -1,3 +1,22 @@
# unreleased
## Features
## Bugfixes
- Fix negative values of N not being parsed in <N:M> line ranges without `=` flag value separator, see #3442 (@lmmx)
## Other
- Improve README documentation on pager options passed to less, see #3443 (@injust)
- Use more robust approach to escaping in Bash completions, see #3448 (@akinomyoga)
## Syntaxes
## Themes
## `bat` as a library
# v0.26.0
## Features
@@ -29,7 +48,7 @@
- Update base16 README links to community driven base16 work #2871 (@JamyGolden)
- Work around build failures when building `bat` from vendored sources #3179 (@dtolnay)
- CICD: Stop building for x86_64-pc-windows-gnu which fails #3261 (Enselic)
- CICD: CICD: replace windows-2019 runners with windows-2025 #3339 (@cyqsimon)
- CICD: replace windows-2019 runners with windows-2025 #3339 (@cyqsimon)
- Build script: replace string-based codegen with quote-based codegen #3340 (@cyqsimon)
- Improve code coverage of `--list-languages` parameter #2942 (@sblondon)
- Only start offload worker thread when there's more than 1 core #2956 (@cyqsimon)

100
Cargo.lock generated
View File

@@ -394,9 +394,9 @@ dependencies = [
[[package]]
name = "darling"
version = "0.20.10"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989"
checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0"
dependencies = [
"darling_core",
"darling_macro",
@@ -404,9 +404,9 @@ dependencies = [
[[package]]
name = "darling_core"
version = "0.20.10"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5"
checksum = "1247195ecd7e3c85f83c8d2a366e4210d588e802133e1e355180a9870b517ea4"
dependencies = [
"fnv",
"ident_case",
@@ -418,9 +418,9 @@ dependencies = [
[[package]]
name = "darling_macro"
version = "0.20.10"
version = "0.21.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806"
checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81"
dependencies = [
"darling_core",
"quote",
@@ -667,9 +667,9 @@ dependencies = [
[[package]]
name = "git2"
version = "0.20.0"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110"
dependencies = [
"bitflags",
"libc",
@@ -932,9 +932,9 @@ checksum = "6a82ae493e598baaea5209805c49bbf2ea7de956d50d7da0da1164f9c6d28543"
[[package]]
name = "libgit2-sys"
version = "0.18.0+1.9.0"
version = "0.18.2+1.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec"
checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222"
dependencies = [
"cc",
"libc",
@@ -1032,13 +1032,13 @@ dependencies = [
[[package]]
name = "mio"
version = "1.0.3"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -1218,9 +1218,9 @@ dependencies = [
[[package]]
name = "prettyplease"
version = "0.2.35"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a"
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
dependencies = [
"proc-macro2",
"syn",
@@ -1284,9 +1284,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.11.1"
version = "1.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
dependencies = [
"aho-corasick",
"memchr",
@@ -1296,9 +1296,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.4.9"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
dependencies = [
"aho-corasick",
"memchr",
@@ -1362,18 +1362,28 @@ checksum = "f79dfe2d285b0488816f30e700a7438c5a73d816b5b7d3ac72fbc48b0d185e03"
[[package]]
name = "serde"
version = "1.0.217"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
"serde_derive",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.217"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
@@ -1403,20 +1413,19 @@ dependencies = [
[[package]]
name = "serde_with"
version = "3.12.0"
version = "3.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa"
checksum = "aa66c845eee442168b2c8134fec70ac50dc20e760769c8ba0ad1319ca1959b04"
dependencies = [
"serde",
"serde_derive",
"serde_core",
"serde_with_macros",
]
[[package]]
name = "serde_with_macros"
version = "3.12.0"
version = "3.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e"
checksum = "b91a903660542fced4e99881aa481bdbaec1634568ee02e0b8bd57c64cb38955"
dependencies = [
"darling",
"proc-macro2",
@@ -1534,9 +1543,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.104"
version = "2.0.108"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40"
checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917"
dependencies = [
"proc-macro2",
"quote",
@@ -1615,28 +1624,28 @@ dependencies = [
[[package]]
name = "terminal-colorsaurus"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f7226dad4b1817567c1e2f5d453897ef36abe79def7783af3fa241a694e30b3"
checksum = "8909f33134da34b43f69145e748790de650a6abd84faf1f82e773444dd293ec8"
dependencies = [
"cfg-if",
"libc",
"memchr",
"mio 1.0.3",
"mio 1.1.0",
"terminal-trx",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
"xterm-color",
]
[[package]]
name = "terminal-trx"
version = "0.2.4"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "975b4233aefa1b02456d5e53b22c61653c743e308c51cf4181191d8ce41753ab"
checksum = "662a3cd5ca570df622e848ef18b50c151e65c9835257465417242243b0bce783"
dependencies = [
"cfg-if",
"libc",
"windows-sys 0.59.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -2011,6 +2020,12 @@ dependencies = [
"syn",
]
[[package]]
name = "windows-link"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-result"
version = "0.1.2"
@@ -2056,6 +2071,15 @@ dependencies = [
"windows-targets 0.53.2",
]
[[package]]
name = "windows-sys"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
]
[[package]]
name = "windows-targets"
version = "0.48.5"

View File

@@ -67,7 +67,7 @@ clircle = { version = "0.6.1", default-features = false }
bugreport = { version = "0.5.0", optional = true }
etcetera = { version = "0.10.0", optional = true }
grep-cli = { version = "0.1.11", optional = true }
regex = { version = "1.10.6", optional = true }
regex = { version = "1.12.2", optional = true }
walkdir = { version = "2.5", optional = true }
bytesize = { version = "1.3.0" }
encoding_rs = "0.8.35"
@@ -112,13 +112,13 @@ anyhow = "1.0.97"
indexmap = { version = "2.8.0", features = ["serde"] }
itertools = "0.14.0"
once_cell = "1.20"
prettyplease = "0.2.35"
prettyplease = "0.2.37"
proc-macro2 = "1.0.95"
quote = "1.0.40"
regex = "1.10.6"
regex = "1.12.2"
serde = "1.0"
serde_derive = "1.0"
serde_with = { version = "3.12.0", default-features = false, features = ["macros"] }
serde_with = { version = "3.15.1", default-features = false, features = ["macros"] }
syn = { version = "2.0.104", features = ["full"] }
toml = { version = "0.9.1", features = ["preserve_order"] }
walkdir = "2.5"

View File

@@ -670,22 +670,22 @@ to improve the experience. Specifically, `-R`/`--RAW-CONTROL-CHARS`, `-F`/`--qui
> - The `--paging=always` argument is used.
> - The `BAT_PAGING` environment is set to `always`.
The `-R` option is needed to interpret ANSI colors correctly.
The `-R`/`--RAW-CONTROL-CHARS` option is needed to interpret ANSI colors correctly.
The `-F` option instructs `less` to exit immediately if the output size is smaller than
The `-F`/`--quit-if-one-screen` option instructs `less` to exit immediately if the output size is smaller than
the vertical size of the terminal. This is convenient for small files because you do not
have to press `q` to quit the pager.
The `-K` option instructs `less` to exit immediately when an interrupt signal is received.
The `-K`/`--quit-on-intr` option instructs `less` to exit immediately when an interrupt signal is received.
This is useful to ensure that `less` quits together with `bat` on SIGINT.
The `-X` option is needed to fix a bug with the `--quit-if-one-screen` feature in versions
of `less` older than version 530. Unfortunately, it also breaks mouse-wheel support in `less`.
The `-X`/`--no-init` option is added to versions of `less` older than version 530 (older than 558 on Windows) to
fix a bug with the `-F`/`--quit-if-one-screen` feature. Unfortunately, it also breaks mouse-wheel support in `less`.
If you want to enable mouse-wheel scrolling on older versions of `less` and do not mind losing
the quit-if-one-screen feature, you can set the pager (via `--pager` or `BAT_PAGER`) to `less -R`.
For `less` 530 or newer, it should work out of the box.
The `-S` option is added when `bat`'s `-S`/`--chop-long-lines` option is used. This tells `less`
The `-S`/`--chop-long-lines` option is added when `bat`'s `-S`/`--chop-long-lines` option is used. This tells `less`
to truncate any lines larger than the terminal width.
### Indentation

View File

@@ -14,18 +14,36 @@ __bat_escape_completions()
{
# Do not escape if completing a quoted value.
[[ $cur == [\"\']* ]] && return 0
# printf -v to an array index is available in bash >= 4.1.
# Use it if available, as -o filenames is semantically incorrect if
# we are not actually completing filenames, and it has side effects
# (e.g. adds trailing slash to candidates matching present dirs).
if ((
BASH_VERSINFO[0] > 5 || \
BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] >= 3
)); then
# bash >= 5.3 has "compopt -o fullquote", which exactly does
# what this function tries to do.
compopt -o fullquote
elif ((
BASH_VERSINFO[0] > 4 || \
BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] > 0
)); then
# printf -v to an array index is available in bash >= 4.1.
# Use it if available, as -o filenames is semantically
# incorrect if we are not actually completing filenames, and it
# has side effects (e.g. adds trailing slash to candidates
# matching present dirs).
local i
for i in ${!COMPREPLY[*]}; do
printf -v "COMPREPLY[i]" %q "${COMPREPLY[i]}"
done
# We can use "compopt -o noquote" available in bash >= 4.3 to
# prevent further quoting by the shell, which would be
# unexpectedly applied when a quoted result matches a filename.
if ((
BASH_VERSINFO[0] > 4 || \
BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3
)); then
compopt -o noquote
fi
else
compopt -o filenames
fi
@@ -66,7 +84,7 @@ _bat() {
printf "%s\n" "$lang"
done
)" -- "$cur"))
__bat_escape_completions
__bat_escape_completions
return 0
;;
-H | --highlight-line | \
@@ -130,16 +148,16 @@ _bat() {
return 0
;;
--theme)
local IFS=$'\n'
COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --list-themes)" -- "$cur"))
__bat_escape_completions
return 0
;;
local IFS=$'\n'
COMPREPLY=($(compgen -W "auto${IFS}auto:always${IFS}auto:system${IFS}dark${IFS}light${IFS}$("$1" --list-themes)" -- "$cur"))
__bat_escape_completions
return 0
;;
--theme-dark | \
--theme-light)
local IFS=$'\n'
COMPREPLY=($(compgen -W "$("$1" --list-themes)" -- "$cur"))
__bat_escape_completions
__bat_escape_completions
return 0
;;
--style)
@@ -158,7 +176,7 @@ _bat() {
numbers
snip
)
# shellcheck disable=SC2016
# shellcheck disable=SC2016
if declare -F _comp_delimited >/dev/null 2>&1; then
# bash-completion > 2.11
_comp_delimited , -W '"${styles[@]}"'

View File

@@ -6,12 +6,12 @@ if you are not looking for a program like `bat`, this comparison might not be fo
| | bat | [pygments](http://pygments.org/) | [highlight](http://www.andre-simon.de/doku/highlight/highlight.php) | [ccat](https://github.com/jingweno/ccat) | [source-highlight](https://www.gnu.org/software/src-highlite/) | [hicat](https://github.com/rstacruz/hicat) | [coderay](https://github.com/rubychan/coderay) | [rouge](https://github.com/jneen/rouge) | [clp](https://github.com/jpe90/clp) |
|----------------------------------------------|---------------------------------------------------------------------|----------------------------------|---------------------------------------------------------------------|------------------------------------------|----------------------------------------------------------------|-----------------------------------------------------|-----------------------------------------------------|-----------------------------------------------------|-----------------------------------------------------|
| Drop-in `cat` replacement | :heavy_check_mark: [*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (:heavy_check_mark:) | :x: | :x: [*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: | :x: |
| Drop-in `cat` replacement | :heavy_check_mark:&nbsp;[*](https://github.com/sharkdp/bat/issues/134) | :x: | :x: | (✔️) | :x: | :x:&nbsp;[*](https://github.com/rstacruz/hicat/issues/6) | :x: | :x: | :x: |
| Git integration | :heavy_check_mark: | :x: | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
| Automatic paging | :heavy_check_mark: | :x: | :x: | :x: | :x: | :heavy_check_mark: | :x: | :x: | :x: |
| Languages (circa) | 150 | 300 | 200 | 7 | 80 | 130 | 30 | 130 | 150 |
| Extensible (languages, themes) | :heavy_check_mark: | (:heavy_check_mark:) | (:heavy_check_mark:) | :x: | (:heavy_check_mark:) | :x: | :x: | :x: | :heavy_check_mark: |
| Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (:heavy_check_mark:) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Extensible (languages, themes) | :heavy_check_mark: | (✔️) | (✔️) | :x: | (✔️) | :x: | :x: | :x: | :heavy_check_mark: |
| Advanced highlighting (e.g. nested syntaxes) | :heavy_check_mark: | :heavy_check_mark: | (✔️) ? | :x: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| Execution time [ms] (`jquery-3.3.1.js`) | 422 | 455 | 299 | 39 | 208 | 287 | 128 | 740 | 22 |
| Execution time [ms] (`miniz.c`) | 27 | 169 | 19 | 4 | 36 | 131 | 58 | 231 | 4 |
| Execution time [ms] (957 kB XML file) | 215 | 296 | 236 | 165 | 83 | 412 | 135 | 386 | 127 |

View File

@@ -194,6 +194,7 @@ Options:
'--line-range :40' prints lines 1 to 40
'--line-range 40:' prints lines 40 to the end of the file
'--line-range 40' only prints line 40
'--line-range -10:' prints the last 10 lines
'--line-range 30:+10' prints lines 30 to 40
'--line-range 35::5' prints lines 30 to 40 (line 35 with 5 lines of context)
'--line-range 30:40:2' prints lines 28 to 42 (range 30-40 with 2 lines of context)

View File

@@ -519,6 +519,7 @@ pub fn build_app(interactive_output: bool) -> Command {
.short('r')
.action(ArgAction::Append)
.value_name("N:M")
.allow_hyphen_values(true)
.help("Only print the lines from N to M.")
.long_help(
"Only print the specified range of lines for each file. \
@@ -527,6 +528,7 @@ pub fn build_app(interactive_output: bool) -> Command {
'--line-range :40' prints lines 1 to 40\n \
'--line-range 40:' prints lines 40 to the end of the file\n \
'--line-range 40' only prints line 40\n \
'--line-range -10:' prints the last 10 lines\n \
'--line-range 30:+10' prints lines 30 to 40\n \
'--line-range 35::5' prints lines 30 to 40 (line 35 with 5 lines of context)\n \
'--line-range 30:40:2' prints lines 28 to 42 (range 30-40 with 2 lines of context)",

View File

@@ -207,7 +207,7 @@ fn line_range_from_back_last_two() {
}
#[test]
fn line_range_from_back_last_two_single_line() {
fn line_range_from_back_last_two_single_line_eq_sep() {
bat()
.arg("single-line.txt")
.arg("--line-range=-2:")
@@ -216,6 +216,17 @@ fn line_range_from_back_last_two_single_line() {
.stdout("Single Line");
}
#[test]
fn line_range_from_back_last_two_single_line_no_sep() {
bat()
.arg("single-line.txt")
.arg("--line-range")
.arg("-2:")
.assert()
.success()
.stdout("Single Line");
}
#[test]
fn line_range_first_two() {
bat()