1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-09-29 00:22:26 +01:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Keith Hall
c4a7d888b7 Add missing shell completions for various CLI arguments 2025-09-27 16:05:26 +03:00
6 changed files with 93 additions and 30 deletions

View File

@@ -21,6 +21,7 @@
- Make --map-syntax target case insensitive to match --language, see #3206 (@keith-hall) - Make --map-syntax target case insensitive to match --language, see #3206 (@keith-hall)
- Correctly determine the end of the line in UTF16LE/BE input #3369 (@keith-hall) - Correctly determine the end of the line in UTF16LE/BE input #3369 (@keith-hall)
- `--style=changes` no longer prints a two-space indent when the file is unmodified, see issue #2710 and PR #3406 (@jyn514) - `--style=changes` no longer prints a two-space indent when the file is unmodified, see issue #2710 and PR #3406 (@jyn514)
- Add missing shell completions, see #3411 (@keith-hall)
## Other ## Other

58
Cargo.lock generated
View File

@@ -157,7 +157,7 @@ dependencies = [
"syntect", "syntect",
"tempfile", "tempfile",
"terminal-colorsaurus", "terminal-colorsaurus",
"thiserror 2.0.16", "thiserror 2.0.11",
"toml", "toml",
"unicode-segmentation", "unicode-segmentation",
"unicode-width", "unicode-width",
@@ -177,18 +177,24 @@ dependencies = [
[[package]] [[package]]
name = "bit-set" name = "bit-set"
version = "0.8.0" version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [ dependencies = [
"bit-vec", "bit-vec",
] ]
[[package]] [[package]]
name = "bit-vec" name = "bit-vec"
version = "0.8.0" version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@@ -374,7 +380,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
"crossterm_winapi", "crossterm_winapi",
"libc", "libc",
"mio 0.8.11", "mio 0.8.11",
@@ -576,13 +582,12 @@ dependencies = [
[[package]] [[package]]
name = "fancy-regex" name = "fancy-regex"
version = "0.16.2" version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "998b056554fbe42e03ae0e152895cd1a7e1002aec800fdc6635d20270260c46f" checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2"
dependencies = [ dependencies = [
"bit-set", "bit-set",
"regex-automata", "regex",
"regex-syntax",
] ]
[[package]] [[package]]
@@ -672,7 +677,7 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff" checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
"libc", "libc",
"libgit2-sys", "libgit2-sys",
"log", "log",
@@ -1057,7 +1062,7 @@ version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6" checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
"cfg-if", "cfg-if",
"cfg_aliases", "cfg_aliases",
"libc", "libc",
@@ -1113,11 +1118,11 @@ dependencies = [
[[package]] [[package]]
name = "onig" name = "onig"
version = "6.5.1" version = "6.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0" checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f"
dependencies = [ dependencies = [
"bitflags", "bitflags 1.3.2",
"libc", "libc",
"once_cell", "once_cell",
"onig_sys", "onig_sys",
@@ -1289,7 +1294,7 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
] ]
[[package]] [[package]]
@@ -1336,7 +1341,7 @@ version = "0.38.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
@@ -1566,11 +1571,12 @@ dependencies = [
[[package]] [[package]]
name = "syntect" name = "syntect"
version = "5.3.0" version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "656b45c05d95a5704399aeef6bd0ddec7b2b3531b7c9e900abbf7c4d2190c925" checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1"
dependencies = [ dependencies = [
"bincode", "bincode",
"bitflags 1.3.2",
"fancy-regex", "fancy-regex",
"flate2", "flate2",
"fnv", "fnv",
@@ -1581,7 +1587,7 @@ dependencies = [
"serde", "serde",
"serde_derive", "serde_derive",
"serde_json", "serde_json",
"thiserror 2.0.16", "thiserror 1.0.69",
"walkdir", "walkdir",
"yaml-rust", "yaml-rust",
] ]
@@ -1685,11 +1691,11 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.16" version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
dependencies = [ dependencies = [
"thiserror-impl 2.0.16", "thiserror-impl 2.0.11",
] ]
[[package]] [[package]]
@@ -1705,9 +1711,9 @@ dependencies = [
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "2.0.16" version = "2.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@@ -2263,7 +2269,7 @@ version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
dependencies = [ dependencies = [
"bitflags", "bitflags 2.6.0",
] ]
[[package]] [[package]]

View File

@@ -11,7 +11,7 @@ exclude = ["assets/syntaxes/*", "assets/themes/*"]
build = "build/main.rs" build = "build/main.rs"
edition = '2021' edition = '2021'
# You are free to bump MSRV as soon as a reason for bumping emerges. # You are free to bump MSRV as soon as a reason for bumping emerges.
rust-version = "1.79" rust-version = "1.74"
[features] [features]
default = ["application"] default = ["application"]
@@ -82,7 +82,7 @@ optional = true
default-features = false default-features = false
[dependencies.syntect] [dependencies.syntect]
version = "5.3.0" version = "5.2.0"
default-features = false default-features = false
features = ["parsing"] features = ["parsing"]

View File

@@ -80,6 +80,7 @@ _bat() {
--line-range | \ --line-range | \
-L | --list-languages | \ -L | --list-languages | \
--lessopen | \ --lessopen | \
--no-paging | \
--diagnostic | \ --diagnostic | \
--acknowledgements | \ --acknowledgements | \
-h | --help | \ -h | --help | \
@@ -100,6 +101,22 @@ _bat() {
COMPREPLY=($(compgen -W "auto never character" -- "$cur")) COMPREPLY=($(compgen -W "auto never character" -- "$cur"))
return 0 return 0
;; ;;
--binary)
COMPREPLY=($(compgen -W "no-printing as-text" -- "$cur"))
return 0
;;
--nonprintable-notation)
COMPREPLY=($(compgen -W "unicode caret" -- "$cur"))
return 0
;;
--strip-ansi)
COMPREPLY=($(compgen -W "auto never always" -- "$cur"))
return 0
;;
--completion)
COMPREPLY=($(compgen -W "bash fish zsh ps1" -- "$cur"))
return 0
;;
--color | --decorations | --paging) --color | --decorations | --paging)
COMPREPLY=($(compgen -W "auto never always" -- "$cur")) COMPREPLY=($(compgen -W "auto never always" -- "$cur"))
return 0 return 0
@@ -157,6 +174,8 @@ _bat() {
# --unbuffered excluded intentionally (no-op) # --unbuffered excluded intentionally (no-op)
COMPREPLY=($(compgen -W " COMPREPLY=($(compgen -W "
--show-all --show-all
--nonprintable-notation
--binary
--plain --plain
--language --language
--highlight-line --highlight-line
@@ -173,6 +192,7 @@ _bat() {
--decorations --decorations
--force-colorization --force-colorization
--paging --paging
--no-paging
--pager --pager
--map-syntax --map-syntax
--ignored-suffix --ignored-suffix
@@ -182,10 +202,12 @@ _bat() {
--list-themes --list-themes
--squeeze-blank --squeeze-blank
--squeeze-limit --squeeze-limit
--strip-ansi
--style --style
--line-range --line-range
--list-languages --list-languages
--lessopen --lessopen
--completion
--diagnostic --diagnostic
--acknowledgements --acknowledgements
--set-terminal-title --set-terminal-title

View File

@@ -142,10 +142,16 @@ set -l special_themes '
complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg complete -c $bat -l acknowledgements -d "Print acknowledgements" -n __fish_is_first_arg
complete -c $bat -l binary -x -a "no-printing as-text" -d "How to treat binary content" -n __bat_no_excl_args
complete -c $bat -l cache-dir -f -d "Show bat's cache directory" -n __fish_is_first_arg complete -c $bat -l cache-dir -f -d "Show bat's cache directory" -n __fish_is_first_arg
complete -c $bat -s c -l chop-long-lines -d "Truncate all lines longer than screen width" -n __bat_no_excl_args
complete -c $bat -l color -x -a "$color_opts" -d "When to use colored output" -n __bat_no_excl_args complete -c $bat -l color -x -a "$color_opts" -d "When to use colored output" -n __bat_no_excl_args
complete -c $bat -l completion -x -a "bash fish zsh ps1" -d "Show shell completion for a certain shell" -n __fish_is_first_arg
complete -c $bat -l config-dir -f -d "Display location of configuration directory" -n __fish_is_first_arg complete -c $bat -l config-dir -f -d "Display location of configuration directory" -n __fish_is_first_arg
complete -c $bat -l config-file -f -d "Display location of configuration file" -n __fish_is_first_arg complete -c $bat -l config-file -f -d "Display location of configuration file" -n __fish_is_first_arg
@@ -192,20 +198,34 @@ complete -c $bat -l no-custom-assets -d "Do not load custom assets"
complete -c $bat -l no-lessopen -d "Disable the $LESSOPEN preprocessor if enabled (overrides --lessopen)" complete -c $bat -l no-lessopen -d "Disable the $LESSOPEN preprocessor if enabled (overrides --lessopen)"
complete -c $bat -l nonprintable-notation -x -a "unicode caret" -d "Set notation for non-printable characters" -n __bat_no_excl_args
complete -c $bat -s n -l number -d "Only show line numbers, no other decorations" -n __bat_no_excl_args complete -c $bat -s n -l number -d "Only show line numbers, no other decorations" -n __bat_no_excl_args
complete -c $bat -l no-paging -d "Alias for --paging=never" -n __bat_no_excl_args
complete -c $bat -l pager -x -a "$pager_opts" -d "Which pager to use" -n __bat_no_excl_args complete -c $bat -l pager -x -a "$pager_opts" -d "Which pager to use" -n __bat_no_excl_args
complete -c $bat -l paging -x -a "$paging_opts" -d "When to use the pager" -n __bat_no_excl_args complete -c $bat -l paging -x -a "$paging_opts" -d "When to use the pager" -n __bat_no_excl_args
complete -c $bat -s p -l plain -d "Show plain style" -n __bat_no_excl_args
complete -c $bat -l set-terminal-title -d "Sets terminal title to filenames when using a pager" -n __bat_no_excl_args
complete -c $bat -s A -l show-all -d "Show non-printable characters" -n __bat_no_excl_args
complete -c $bat -s s -l squeeze-blank -d "Squeeze consecutive empty lines into a single empty line" -n __bat_no_excl_args
complete -c $bat -l squeeze-limit -x -d "Set the maximum number of consecutive empty lines to be printed" -n __bat_no_excl_args
complete -c $bat -l strip-ansi -x -a "auto never always" -d "Specify when to strip ANSI escape sequences from the input" -n __bat_no_excl_args
complete -c $bat -s p -l plain -d "Disable decorations" -n __bat_no_excl_args complete -c $bat -s p -l plain -d "Disable decorations" -n __bat_no_excl_args
complete -c $bat -o pp -d "Disable decorations and paging" -n __bat_no_excl_args complete -c $bat -o pp -d "Disable decorations and paging" -n __bat_no_excl_args
complete -c $bat -s P -d "Disable paging" -n __bat_no_excl_args complete -c $bat -s P -d "Disable paging" -n __bat_no_excl_args
complete -c $bat -s A -l show-all -d "Show non-printable characters" -n __bat_no_excl_args
complete -c $bat -l style -x -k -a "(__fish_complete_list , __bat_style_opts)" -d "Specify which non-content elements to display" -n __bat_no_excl_args complete -c $bat -l style -x -k -a "(__fish_complete_list , __bat_style_opts)" -d "Specify which non-content elements to display" -n __bat_no_excl_args
complete -c $bat -l tabs -x -a "$tabs_opts" -d "Set tab width" -n __bat_no_excl_args complete -c $bat -l tabs -x -a "$tabs_opts" -d "Set tab width" -n __bat_no_excl_args
@@ -218,6 +238,8 @@ complete -c $bat -l theme-dark -x -a "(command $bat --list-themes | command cat)
complete -c $bat -l theme-light -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme for light backgrounds" -n __bat_no_excl_args complete -c $bat -l theme-light -x -a "(command $bat --list-themes | command cat)" -d "Set the syntax highlighting theme for light backgrounds" -n __bat_no_excl_args
complete -c $bat -s u -l unbuffered -d "This option exists for POSIX-compliance reasons" -n __bat_no_excl_args
complete -c $bat -s V -l version -f -d "Show version information" -n __fish_is_first_arg complete -c $bat -s V -l version -f -d "Show version information" -n __fish_is_first_arg
complete -c $bat -l wrap -x -a "$wrap_opts" -d "Text-wrapping mode" -n __bat_no_excl_args complete -c $bat -l wrap -x -a "$wrap_opts" -d "Text-wrapping mode" -n __bat_no_excl_args

View File

@@ -26,6 +26,7 @@ _{{PROJECT_EXECUTABLE}}_main() {
args=( args=(
'(-A --show-all)'{-A,--show-all}'[show non-printable characters (space, tab, newline, ..)]' '(-A --show-all)'{-A,--show-all}'[show non-printable characters (space, tab, newline, ..)]'
--nonprintable-notation='[specify how to display non-printable characters when using --show-all]:notation:(caret unicode)' --nonprintable-notation='[specify how to display non-printable characters when using --show-all]:notation:(caret unicode)'
--binary='[specify how to treat binary content]:behavior:(no-printing as-text)'
\*{-p,--plain}'[show plain style (alias for `--style=plain`), repeat twice to disable automatic paging (alias for `--paging=never`)]' \*{-p,--plain}'[show plain style (alias for `--style=plain`), repeat twice to disable automatic paging (alias for `--paging=never`)]'
'(-l --language)'{-l+,--language=}'[set the language for syntax highlighting]:language:->languages' '(-l --language)'{-l+,--language=}'[set the language for syntax highlighting]:language:->languages'
\*{-H+,--highlight-line=}'[highlight specified block of lines]:start\:end' \*{-H+,--highlight-line=}'[highlight specified block of lines]:start\:end'
@@ -40,16 +41,27 @@ _{{PROJECT_EXECUTABLE}}_main() {
--color='[specify when to use colors]:when:(auto never always)' --color='[specify when to use colors]:when:(auto never always)'
--italic-text='[use italics in output]:when:(always never)' --italic-text='[use italics in output]:when:(always never)'
--decorations='[specify when to show the decorations]:when:(auto never always)' --decorations='[specify when to show the decorations]:when:(auto never always)'
'(-f --force-colorization)'--force-colorization'[force colorization and decorations]'
--paging='[specify when to use the pager]:when:(auto never always)' --paging='[specify when to use the pager]:when:(auto never always)'
'(-P --no-paging)'--no-paging'[alias for --paging=never]'
--pager='[determine which pager to use]:command:'
'(-m --map-syntax)'{-m+,--map-syntax=}'[map a glob pattern to an existing syntax name]: :->syntax-maps' '(-m --map-syntax)'{-m+,--map-syntax=}'[map a glob pattern to an existing syntax name]: :->syntax-maps'
--ignored-suffix='[ignore extension]:suffix:'
'(--theme)'--theme='[set the color theme for syntax highlighting]:theme:->theme_preferences' '(--theme)'--theme='[set the color theme for syntax highlighting]:theme:->theme_preferences'
'(--theme-dark)'--theme-dark='[set the color theme for syntax highlighting for dark backgrounds]:theme:->themes' '(--theme-dark)'--theme-dark='[set the color theme for syntax highlighting for dark backgrounds]:theme:->themes'
'(--theme-light)'--theme-light='[set the color theme for syntax highlighting for light backgrounds]:theme:->themes' '(--theme-light)'--theme-light='[set the color theme for syntax highlighting for light backgrounds]:theme:->themes'
'(: --list-themes --list-languages -L)'--list-themes'[show all supported highlighting themes]' '(: --list-themes --list-languages -L)'--list-themes'[show all supported highlighting themes]'
--squeeze-blank'[squeeze consecutive empty lines into a single empty line]'
--squeeze-limit='[set the maximum number of consecutive empty lines]:limit:'
--strip-ansi='[specify when to strip ANSI escape sequences]:when:(auto never always)'
--style='[comma-separated list of style elements to display]: : _values "style [default]" --style='[comma-separated list of style elements to display]: : _values "style [default]"
default auto full plain changes header header-filename header-filesize grid rule numbers snip' default auto full plain changes header header-filename header-filesize grid rule numbers snip'
\*{-r+,--line-range=}'[only print the specified line range]:start\:end' \*{-r+,--line-range=}'[only print the specified line range]:start\:end'
'(* -)'{-L,--list-languages}'[display all supported languages]' '(* -)'{-L,--list-languages}'[display all supported languages]'
'(-u --unbuffered)'--unbuffered'[this option exists for POSIX-compliance reasons]'
--completion='[show shell completion for a certain shell]:shell:(bash fish zsh ps1)'
--set-terminal-title'[sets terminal title to filenames when using a pager]'
--diagnostic'[show diagnostic information for bug reports]'
-P'[disable paging]' -P'[disable paging]'
"--no-config[don't use the configuration file]" "--no-config[don't use the configuration file]"
"--no-custom-assets[don't load custom assets]" "--no-custom-assets[don't load custom assets]"