diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-04 23:32:11 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-09-04 23:32:11 +0200 |
commit | 6aa154540a5dfba45edf26e5d167783dd2b8d57c (patch) | |
tree | 5e7754e8c4c1282775b0c950e24957ea4631a482 /provides/zsh/completions/_pkg | |
parent | c857a0fa576a134e905f1d653d79a2c46583c410 (diff) |
completion: No more eval
Diffstat (limited to 'provides/zsh/completions/_pkg')
-rw-r--r-- | provides/zsh/completions/_pkg | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/provides/zsh/completions/_pkg b/provides/zsh/completions/_pkg index 8a621a6..e4ecfff 100644 --- a/provides/zsh/completions/_pkg +++ b/provides/zsh/completions/_pkg @@ -5,32 +5,36 @@ ## https://derf.homelinux.org/~derf/dotfiles/zsh/completions/_pkg ## see also: https://derf.homelinux.org/~derf/code/lighty-stats -local arguments_action arguments_list arguments_listall -local all installed +typeset expl -all='pkg list-all' -installed='pkg list' -notinstalled='diff <(eval $installed) <(eval $all) | grep "^>" | cut -d " " -f 2' +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) +} -arguments_action=( - '1:action:(add install changelog changeroot check delete remove info list list-all local-update log push remote-update status update upgrade)' -) -arguments_list=( - '2:package:($(eval $installed))' -) -arguments_listall=( - '2:package:($(eval $all))' -) -arguments_notinstalled=( - '2:package:($(eval $notinstalled))' -) +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 -ge 3 ]] { +if (( CURRENT >= 3 )) { case ${words[2]} in - changelog|check|delete|log|push|remove|status|upgrade) _arguments -s $arguments_list ;; - info) _arguments -s $arguments_listall ;; - add|install) _arguments -s $arguments_notinstalled ;; + 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 $arguments_action + _arguments -s '1: :_pkg_action' } |