diff options
Diffstat (limited to 'Completion/Debian/_deb_packages')
-rw-r--r-- | Completion/Debian/_deb_packages | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Completion/Debian/_deb_packages b/Completion/Debian/_deb_packages index b5e4ffd85..cb74137bf 100644 --- a/Completion/Debian/_deb_packages +++ b/Completion/Debian/_deb_packages @@ -1,7 +1,27 @@ #autoload -if (( ! $+_deb_packages )); then - _deb_packages=( $(awk '/^Package:/ { print $2 }' /var/lib/dpkg/status) ) +# 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 -compadd "$@" - $_deb_packages +local command="$1" +shift + +case "$command" in + installed) compadd "$@" - $_deb_cache_installed;; + uninstalled) compadd "$@" - $_deb_cache_uninstalled;; + avail) compadd "$@" - $_deb_cache_avail;; +esac |