Add shell completions for bash and zsh #298
21
contrib/bash-completion.sh
Normal file
21
contrib/bash-completion.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
: ${PROG:=$(basename ${BASH_SOURCE})}
|
||||
|
||||
_cli_bash_autocomplete() {
|
||||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
|
||||
local cur opts base
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
if [[ "$cur" == "-"* ]]; then
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
|
||||
else
|
||||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
|
||||
fi
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG
|
||||
unset PROG
|
18
contrib/zsh-completion.zsh
Normal file
18
contrib/zsh-completion.zsh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#compdef _tea tea
|
||||
|
||||
|
||||
|
||||
_tea() {
|
||||
local curcontext="$curcontext" state state_descr line="$line"
|
||||
local ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C '*::command:->command' ':options:->options'
|
||||
|
||||
list=(${(f)"$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 tea $line --generate-bash-completion)"})
|
||||
|
||||
_describe -t tea-subcommands 'tea subcommands' list && ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_tea "$@"
|
Loading…
Reference in New Issue
Block a user
I think we should include the official script https://github.com/urfave/cli/blob/master/autocomplete/zsh_autocomplete