formatted apm completion and used helper function

pull/1782/head
Gurkirat Singh 2021-01-10 19:18:41 +05:30
parent 2c39053879
commit f71d76990a
No known key found for this signature in database
GPG Key ID: CFD64E1DCB3DA835
1 changed files with 55 additions and 50 deletions

View File

@ -24,7 +24,9 @@
# repo: https://github.com/vigo/apm-bash-completion # repo: https://github.com/vigo/apm-bash-completion
__apm(){ if _command_exists apm
then
function __apm(){
local cur prev options apm_command local cur prev options apm_command
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
@ -50,8 +52,9 @@ __apm(){
fi fi
fi fi
COMPREPLY=($(compgen -W "$options" -- "$cur")) COMPREPLY=($(compgen -W "$options" -- "$cur"))
} }
__apm_get_command() {
function __apm_get_command() {
local i local i
for ((i=1; i < $COMP_CWORD; ++i)); do for ((i=1; i < $COMP_CWORD; ++i)); do
local arg=${COMP_WORDS[$i]} local arg=${COMP_WORDS[$i]}
@ -73,5 +76,7 @@ __apm_get_command() {
return;; return;;
esac esac
done done
} }
complete -F __apm -o bashdefault -o default apm
complete -F __apm -o bashdefault -o default apm
fi