1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-17 22:31:12 +01:00
zsh/Completion/Debian/_deb_packages

58 lines
1.4 KiB
Text
Raw Normal View History

1999-09-02 23:27:08 +02:00
#autoload
1999-12-27 22:22:24 +01:00
# Usage: _deb_packages expl... avail|installed|uninstalled
2000-01-30 02:21:33 +01:00
_deb_packages_update_avail () {
2000-02-05 08:00:31 +01:00
if (( ! $+_deb_packages_cache_avail )); then
1999-12-27 22:22:24 +01:00
_deb_packages_cache_avail=(
${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"}
)
fi
cachevar=_deb_packages_cache_avail
}
2000-01-30 02:21:33 +01:00
_deb_packages_update_installed () {
1999-12-27 22:22:24 +01:00
if (( ! $+_deb_packages_cache_installed )); then
_deb_packages_cache_installed=(
${${${(f)"$(dpkg --get-selections)"}:#*deinstall}%% *}
)
fi
cachevar=_deb_packages_cache_installed
}
2000-01-30 02:21:33 +01:00
_deb_packages_update_uninstalled () {
_deb_packages_update_avail
_deb_packages_update_installed
1999-12-27 22:22:24 +01:00
if (( ! $+_deb_packages_cache_uninstalled )); then
_deb_packages_cache_uninstalled=(
${_deb_packages_cache_avail:#${(j:|:)~${_deb_packages_cache_installed:q}}}
)
fi
cachevar=_deb_packages_cache_uninstalled
}
_deb_packages () {
2000-01-30 01:59:22 +01:00
local command="$argv[$#]" expl cachevar pkgset
1999-12-27 22:22:24 +01:00
[[ "$command" = (installed|uninstalled|avail) ]] || {
_message "_deb_packages:unknown command: $command"
return
}
2000-02-03 18:22:40 +01:00
zstyle -s ":completion:${curcontext}:" packageset pkgset
2000-01-30 01:59:22 +01:00
[[ "$pkgset" = (installed|uninstalled|avail|available) ]] || {
pkgset="$command"
}
[[ "$pkgset" = "available" ]] && pkgset="avail"
1999-12-27 22:22:24 +01:00
expl=("${(@)argv[1,-2]}")
2000-01-30 02:21:33 +01:00
_deb_packages_update_$pkgset
1999-12-27 22:22:24 +01:00
2000-03-23 05:19:26 +01:00
_wanted packages && compadd "$expl[@]" - "${(@P)cachevar}"
1999-12-27 22:22:24 +01:00
}
_deb_packages "$@"