mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-23 05:58:56 +01:00
Fix zsh completion
* Fix completion for -p option (#1320) * Use prefixed function names to avoid name clash
This commit is contained in:
parent
5d9adc14e7
commit
6bf7b79f13
20
assets/completions/bat.zsh.in
vendored
20
assets/completions/bat.zsh.in
vendored
@ -3,8 +3,8 @@
|
|||||||
local context state state_descr line
|
local context state state_descr line
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
|
||||||
(( $+functions[_cache_subcommand] )) ||
|
(( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) ||
|
||||||
_cache_subcommand() {
|
_{{PROJECT_EXECUTABLE}}_cache_subcommand() {
|
||||||
local -a args
|
local -a args
|
||||||
args=(
|
args=(
|
||||||
'(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
|
'(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
|
||||||
@ -19,12 +19,12 @@ _cache_subcommand() {
|
|||||||
_arguments -S -s $args
|
_arguments -S -s $args
|
||||||
}
|
}
|
||||||
|
|
||||||
(( $+functions[_main] )) ||
|
(( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) ||
|
||||||
_main() {
|
_{{PROJECT_EXECUTABLE}}_main() {
|
||||||
local -a args
|
local -a args
|
||||||
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, ..)]'
|
||||||
{-p,--plain}'[Show plain style (alias for `--style=plain`)]:When `-p` is used twice (`-pp`), it also disables automatic paging (alias for `--style=plain --paging=never`)'
|
'*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]'
|
||||||
'(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
|
'(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
|
||||||
'(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
|
'(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
|
||||||
'(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
|
'(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
|
||||||
@ -51,13 +51,13 @@ _main() {
|
|||||||
|
|
||||||
_arguments -S -s $args
|
_arguments -S -s $args
|
||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
language)
|
language)
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local -a languages
|
local -a languages
|
||||||
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
|
||||||
|
|
||||||
_describe 'language' languages
|
_describe 'language' languages
|
||||||
;;
|
;;
|
||||||
|
|
||||||
theme)
|
theme)
|
||||||
@ -79,15 +79,15 @@ if (( ${#words} == 2 )); then
|
|||||||
local -a subcommands
|
local -a subcommands
|
||||||
subcommands=('cache:Modify the syntax-definition and theme cache')
|
subcommands=('cache:Modify the syntax-definition and theme cache')
|
||||||
_describe subcommand subcommands
|
_describe subcommand subcommands
|
||||||
_main
|
_{{PROJECT_EXECUTABLE}}_main
|
||||||
else
|
else
|
||||||
case $words[2] in
|
case $words[2] in
|
||||||
cache)
|
cache)
|
||||||
_cache_subcommand
|
_{{PROJECT_EXECUTABLE}}_cache_subcommand
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
_main
|
_{{PROJECT_EXECUTABLE}}_main
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user