#compdef pkg ## vim:ft=zsh ## pkg completion ## Daniel Friesel ## https://derf.homelinux.org/~derf/dotfiles/zsh/completions/_pkg ## see also: https://derf.homelinux.org/~derf/code/lighty-stats typeset expl function _pkg_action () { _wanted action expl 'action' \ compadd add install changelog changeroot check delete remove info \ list list-all local-update log push remote-update status update upgrade } function _pkg_installed () { _wanted package expl 'local package' \ compadd $(pkg list) } function _pkg_all () { _wanted package expl 'package' \ compadd $(pkg list-all) } function _pkg_notinstalled () { _wanted package expl 'remote package' \ compadd $(diff <(pkg list) <(pkg list-all) | grep "^>" | cut -d " " -f 2) } if (( CURRENT >= 3 )) { case ${words[2]} in changelog|check|delete|log|push|remove|status|upgrade) _arguments -s '2: :_pkg_installed' ;; info) _arguments -s '2: :_pkg_all' ;; add|install) _arguments -s '2: :_pkg_notinstalled' ;; esac } else { _arguments -s '1: :_pkg_action' }