#autoload # Usage: _deb_packages installed|uninstalled|avail if (( ! $+_deb_cache_dpkg_get_selections )); then _deb_cache_dpkg_get_selections=( ${(f)"$(dpkg --get-selections)"} ) _deb_cache_avail=( ${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"} ) _deb_cache_installed=( ${${_deb_cache_dpkg_get_selections:#*deinstall}%% *} ) _deb_cache_uninstalled=( ${_deb_cache_avail:#${(j:|:)~${_deb_cache_installed:q}}} ) fi local command="$1" expl shift _wanted packages expl packages && case "$command" in installed) compadd "$@" - $_deb_cache_installed;; uninstalled) compadd "$@" - $_deb_cache_uninstalled;; avail) compadd "$@" - $_deb_cache_avail;; esac