pkg-get/scripts/pkg-get_completion.sh
2006-07-13 04:21:42 +02:00

71 lines
2.5 KiB
Bash
Executable File

# pkg-get(8) completion by Simone Rota
# derived form Johannes Winkelmann's prt-get completion
# problems: options ending on = should not add a space afterwards
_pkg-get()
{
local cur prev
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W ' \
install depinst update help \
version readme list info path \
search dsearch printf sync \
dependent sysup current lock unlock \
listlocked diff quickdiff depends quickdep \
dup isinst remove listinst' $cur ))
fi
if [ $COMP_CWORD '>' 1 ]; then
if [[ "$cur" != -* ]]; then
case ${COMP_WORDS[1]} in
"install" | "depinst" | "path" | "dependent" | \
"depends" | "quickdep" | "info" | "readme" | \
"isinst" )
plist=`pkg-get list`
if [ ! "$plist" == "" ]; then
COMPREPLY=( $( compgen -W '$plist' $cur ) )
fi
;;
"current"|"lock"|"remove")
plist=`pkg-get listinst`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
"update")
plist=`pkg-get quickdiff`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
"unlock")
plist=`pkg-get listlocked`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
esac
else
case ${COMP_WORDS[1]} in
"install" | "update" | "sysup")
COMPREPLY=( $( compgen -W '-do \
--pre-install \
--post-install \
--install-scripts' \
-- $cur ) )
;;
"dependent" )
COMPREPLY=( $( compgen -W '--all' -- $cur ) )
;;
"printf" )
COMPREPLY=( $( compgen -W '--filter=' -- $cur ) )
;;
esac
fi
fi
return 0
}
complete -F _pkg-get -o default pkg-get