File tree Expand file tree Collapse file tree 1 file changed +26
-16
lines changed Expand file tree Collapse file tree 1 file changed +26
-16
lines changed Original file line number Diff line number Diff line change 1
- #compdef $PROG
1
+ #compdef program
2
+ compdef _program program
2
3
3
- _cli_zsh_autocomplete() {
4
- local -a opts
5
- local cur
6
- cur=${words[-1]}
7
- if [[ "$cur" == "-"* ]]; then
8
- opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-shell-completion)}")
9
- else
10
- opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-shell-completion)}")
11
- fi
4
+ # Replace all occurences of "program" in this file with the actual name of your
5
+ # CLI program. We recommend using Find+Replace feature of your editor. Let's say
6
+ # your CLI program is called "acme", then replace like so:
7
+ # * program => acme
8
+ # * _program => _acme
12
9
13
- if [[ "${opts[1]}" != "" ]]; then
14
- _describe 'values' opts
15
- else
16
- _files
17
- fi
10
+ _program() {
11
+ local -a opts
12
+ local cur
13
+ cur=${words[-1]}
14
+ if [[ "$cur" == "-"* ]]; then
15
+ opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-shell-completion)}")
16
+ else
17
+ opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-shell-completion)}")
18
+ fi
19
+
20
+ if [[ "${opts[1]}" != "" ]]; then
21
+ _describe 'values' opts
22
+ else
23
+ _files
24
+ fi
18
25
}
19
26
20
- compdef _cli_zsh_autocomplete $PROG
27
+ # don't run the completion function when being source-ed or eval-ed
28
+ if [ "$funcstack[1]" = "_program" ]; then
29
+ _program
30
+ fi
You can’t perform that action at this time.
0 commit comments