bb6e3d02fd
Change-Id: I4d427cd89e20e62d6c197e3f098cf4b1502b373b
30 lines
728 B
Plaintext
30 lines
728 B
Plaintext
#compdef gyan
|
|
|
|
local -a nbc _gyan_opts _gyan_flags _gyan_opts_exp cur prev
|
|
|
|
nbc=(${(ps: :)$(_call_program options "$service bash-completion" 2>/dev/null)})
|
|
_gyan_opts=(${nbc:#-*})
|
|
_gyan_flags=(${(M)nbc:#-*})
|
|
_gyan_opt_exp=${${nbc:#-*}// /|}
|
|
cur=$words[CURRENT]
|
|
prev=$words[(( CURRENT - 1 ))]
|
|
|
|
_checkcomp(){
|
|
for word in $words[@]; do
|
|
if [[ -n ${_gyan_opts[(r)$word]} ]]; then
|
|
return 0
|
|
fi
|
|
done
|
|
return 1
|
|
}
|
|
|
|
echo $_gyan_opts[@] |grep --color gyan
|
|
if [[ "$prev" != "help" ]] && _checkcomp; then
|
|
COMPLETION_CACHE=(~/.gyanclient/*/*-cache)
|
|
cflags=($_gyan_flags[@] ${(ps: :)$(cat $COMPLETION_CACHE 2>/dev/null)})
|
|
compadd "$@" -d $cflags[@]
|
|
else
|
|
compadd "$@" -d $_gyan_opts[@]
|
|
fi
|
|
|