Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] completion for opensolaris IPS package manager



I started working on some scripts for opensolaris commands (zpool, zfs, beadm and more are in the works). Here is the first for package management. It's still pretty basic but supports the features that are used the most (or at least i use the most ^^)

#compdef pkg

cmds=(
       'install:install a package'
    'uninstall:uninstall a package'
    'verify:verify a package'
    'info:fetch package info'
    'contents:show package contents'
    'list:list installed packages'
    'search:search for a package'
    'refresh:refresh catalogues'
    'image-create:create new image'
    'image-update:update an image'
    'set-authority:set an authority'
    'unset-authority:unset an authority'
    'authority:list authorities'
    'rebuild-index:rebuild index'
)

_pkg () {
   ret=1
   SHIFTER=0
   if [[ $words[2] == "-R" ]]; then
       if (( CURRENT == 3 )); then
           _directories && ret=0
           return ret
       elif (( CURRENT >= 4 )); then
           SHIFTER=2
       fi
   fi

   if (( CURRENT-SHIFTER == 2 )); then
       _describe 'pkg command' cmds && ret=0
   else
       case ${words[$(( 2 + SHIFTER ))]} in
           install)
compadd $(awk $'{print $3}' $(find /var/pkg/catalog -name catalog -type f) | sort -u) && ret=0
               ;;
           uninstall|verify)
compadd $(/usr/bin/ls /var/pkg/state/installed | cut -d@ -f1) && ret=0
               ;;
           search|info|contents)
               if [[ $words[$(( 3 + SHIFTER ))] == "-r" ]]; then
compadd $(awk $'{print $3}' $(find /var/pkg/catalog -name catalog -type f) | sort -u) && ret=0
               else
compadd $(/usr/bin/ls /var/pkg/state/installed | cut -d@ -f1) && ret=0
               fi
               ;;
           refresh|unset-authority)
compadd $(find /var/pkg/catalog/ -type d | sed 1d | cut -d/ -f5) && ret=0
       esac
   fi
   return ret
}

Regards,
Björn



Messages sorted by: Reverse Date, Date, Thread, Author