From 5fcfd1f07e71f24d4a43cac970ec39b514154d69 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 3 Sep 1999 23:19:14 +0000 Subject: zsh-workers/7641 --- Completion/Debian/_deb_packages | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'Completion/Debian/_deb_packages') 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 -- cgit 1.4.1