Add shell completions for bash and zsh #298

Closed
YakoYakoYokuYoku wants to merge 1 commits from YakoYakoYokuYoku:shcompl into main
2 changed files with 39 additions and 0 deletions

@ -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

@ -0,0 +1,18 @@
#compdef _tea tea
Outdated
Review

I think we should include the official script https://github.com/urfave/cli/blob/master/autocomplete/zsh_autocomplete

I think we should include the official script https://github.com/urfave/cli/blob/master/autocomplete/zsh_autocomplete
_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 "$@"