#compdef packer packer.static=packer # copy this file to /usr/share/zsh/site-functions/_packer typeset -A opt_args # options for passing to _arguments: main packer commands _packer_opts_commands=( '-Ss[Search for a package.]:*:search text:->sync_search' '-S[Install a package.]' '-Syu[Sync with repositories.]' '-Si[Show information for a package.]' '-G[Just download and extract AUR tarball]' '-h[Show packer usage.]' ) # options for passing to _arguments: options common to all commands _packer_opts_common=( '--ignore[Ignore packages listed here.]:package:_packer_completions_all_packages' '--noconfirm[Do not ask user for confirmation.]' '--noedit[Do not ask user if he wants to edit files.]' '--auronly[Only perform commands for the AUR.]' '--devel[Update development packages. (cvs, git, ...)]' '--skipinteg[Skip the integrity checks.]' ) # handles cases where no subcommand has yet been given _packer_action_none() { _arguments -s : \ "$_packer_opts_commands[@]" } # handles --sync subcommand _packer_action_sync() { local context state line typeset -A opt_args # _arguments -s : \ # "$_packer_opts_common[@]" \ # "$_packer_opts_sync_actions[@]" #\ # #"$_packer_opts_sync_modifiers[@]" case $state in sync_search) _arguments -s : \ "$_packer_opts_common[@]" \ '*:search text: ' ;; *) _arguments -s : \ "$_packer_opts_common[@]" \ '*:package:_packer_completions_all_packages' ;; esac } # provides completions for package groups _packer_completions_all_groups() { local -a cmd groups _packer_get_command groups=( $(_call_program groups $cmd[@] -Sg) ) typeset -U groups compadd "$@" -a groups } # provides completions for packages available from repositories # these can be specified as either 'package' or 'repository/package' _packer_completions_all_packages() { local -a cmd packages repositories packages_long _packer_get_command if compset -P1 '*/*'; then packages=( $(_call_program packages $cmd[@] -Sql ${words[CURRENT]%/*}) ) typeset -U packages _wanted repo_packages expl "repository/package" compadd ${(@)packages} else packages=( $(_call_program packages $cmd[@] -Sql) ) typeset -U packages _wanted packages expl "packages" compadd - "${(@)packages}" repositories=(${(o)${${${(M)${(f)"$(