on master help sign in
Fix zsh completion

* Fix completion for -p option (#1320) * Use prefixed function names to avoid name clash

commit6bf7b79f13b308d6b14d5dfb78ba348922c4cf5b authorAlbert Safin <xzfcpw@gmail.com> dateSat 17 Oct 2020, 06:47 (6 years ago) parent5d9adc1
1 file changed+10−10
assets/completions/bat.zsh.in+10−10
assets/completions/bat.zsh.in+10−10
@@ -3,8 +3,8 @@
33local context state state_descr line
44typeset -A opt_args
55
6−(( $+functions[_cache_subcommand] )) ||
7−_cache_subcommand() {
6+(( $+functions[_{{PROJECT_EXECUTABLE}}_cache_subcommand] )) ||
7+_{{PROJECT_EXECUTABLE}}_cache_subcommand() {
88 local -a args
99 args=(
1010 '(-b --build -c --clear)'{-b,--build}'[Initialize or update the syntax/theme cache]'
@@ -19,12 +19,12 @@ _cache_subcommand() {
1919 _arguments -S -s $args
2020}
2121
22−(( $+functions[_main] )) ||
23−_main() {
22+(( $+functions[_{{PROJECT_EXECUTABLE}}_main] )) ||
23+_{{PROJECT_EXECUTABLE}}_main() {
2424 local -a args
2525 args=(
2626 '(-A --show-all)'{-A,--show-all}'[Show non-printable characters (space, tab, newline, ..)]'
27− {-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`)'
27+ '*'{-p,--plain}'[Show plain style (alias for `--style=plain`), repeat twice to disable disable automatic paging (alias for `--paging=never`)]'
2828 '(-l --language)'{-l+,--language=}'[Set the language for syntax highlighting]:<language>:->language'
2929 '(-H --highlight-line)'{-H,--highlight-line}'[Highlight lines N through M]:<N\:M>...'
3030 '(--file-name)'--file-name'[Specify the name to display for a file]:<name>...:_files'
@@ -51,13 +51,13 @@ _main() {
5151
5252 _arguments -S -s $args
5353
54− case "$state" in
54+ case "$state" in
5555 language)
5656 local IFS=$'\n'
5757 local -a languages
5858 languages=( $({{PROJECT_EXECUTABLE}} --list-languages | awk -F':|,' '{ for (i = 1; i <= NF; ++i) printf("%s:%s\n", $i, $1) }') )
5959
60− _describe 'language' languages
60+ _describe 'language' languages
6161 ;;
6262
6363 theme)
@@ -79,15 +79,15 @@ if (( ${#words} == 2 )); then
7979 local -a subcommands
8080 subcommands=('cache:Modify the syntax-definition and theme cache')
8181 _describe subcommand subcommands
82− _main
82+ _{{PROJECT_EXECUTABLE}}_main
8383else
8484 case $words[2] in
8585 cache)
86− _cache_subcommand
86+ _{{PROJECT_EXECUTABLE}}_cache_subcommand
8787 ;;
8888
8989 *)
90− _main
90+ _{{PROJECT_EXECUTABLE}}_main
9191 ;;
9292 esac
9393fi