diff options
Diffstat (limited to 'scripts/pkg-get_completion.sh')
-rwxr-xr-x | scripts/pkg-get_completion.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/scripts/pkg-get_completion.sh b/scripts/pkg-get_completion.sh new file mode 100755 index 0000000..d65366c --- /dev/null +++ b/scripts/pkg-get_completion.sh @@ -0,0 +1,70 @@ +# 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 |