limit remove completion to installed

This commit is contained in:
zawz 2020-06-29 16:39:05 +02:00
parent 679761135c
commit b8dac99280

View file

@ -3,12 +3,15 @@
_zpkg_completion() _zpkg_completion()
{ {
_cw1="deploy update update-database install remove fetch show deps info list list-all list-outdated list-removed" _cw1="deploy update update-database install remove fetch show deps info list list-all list-outdated list-removed"
_cw1_pkgw="install remove fetch show deps info" _cw1_pkg_all="install fetch show deps info"
_cw1_pkg_installed="remove"
_cw1_file="deploy" _cw1_file="deploy"
if [ "$COMP_CWORD" = "1" ] ; then if [ "$COMP_CWORD" = "1" ] ; then
_compwords=$_cw1 _compwords="$_cw1"
elif [ "$COMP_CWORD" -gt "1" ] && echo "$_cw1_pkgw" | grep -qw -- "${COMP_WORDS[1]}" ; then elif [ "$COMP_CWORD" -gt "1" ] && echo "$_cw1_pkg_all" | grep -qw -- "${COMP_WORDS[1]}" ; then
_compwords=$(zpkg list-all 2>/dev/null) _compwords=$(zpkg list-all 2>/dev/null)
elif [ "$COMP_CWORD" -gt "1" ] && echo "$_cw1_pkg_installed" | grep -qw -- "${COMP_WORDS[1]}" ; then
_compwords=$(zpkg list 2>/dev/null)
fi fi
COMPREPLY=($(compgen -W "$_compwords" "${COMP_WORDS[$COMP_CWORD]}" 2>/dev/null)) COMPREPLY=($(compgen -W "$_compwords" "${COMP_WORDS[$COMP_CWORD]}" 2>/dev/null))
} }