实例1:
function _bigtool() {
COMPREPLY=()
local cur=${COMP_WORDS[COMP_CWORD]};
local com=${COMP_WORDS[COMP_CWORD-1]};
case $com in
'vs')
COMPREPLY=($(compgen -W 'checkout display remove add' -- $cur))
;;
*)
;;
esac
return 0
}
complete -F _bigtool vs
实例2:
_foo()
{
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W "exec help test" -- $cur) )
}
complete -F _foo foo
标签:shell,cur,CWORD,COMP,COMPREPLY,WORDS,linux,foo,补全
From: https://www.cnblogs.com/cenidema/p/17812460.html