Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] _apt: Complete package versions in the 'packagename=<version>' syntax.
- X-seq: zsh-workers 39374
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] _apt: Complete package versions in the 'packagename=<version>' syntax.
- Date: Sat, 17 Sep 2016 09:44:00 +0000
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:message-id:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=1kUCOuf2YjndZfoT01uEqmbMHrw=; b=H6OMks Xt9q+vikiiRdL5cS4irut36U0KiQCDHbzOgNODyBdI3jIJQZWCN4QlYBJm4CI6b7 UkIGpYgNCggQdFNTgsdY60bCGnlkKo4xslSHImbdoNoxtQmZBOu+7wRhASueyZWd 9uc0h/RI/jfI9V5eWRWgd5ADJJswxLR8bfa+k=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:message-id:subject:to :x-sasl-enc:x-sasl-enc; s=smtpout; bh=1kUCOuf2YjndZfoT01uEqmbMHr w=; b=XVTHlKCjM2m202CEJTZww/0ZBTZ2bFGhqB+pqifrtXKuZk68zVTfwaCijE bb8zFhR2zyc17na0fBxTzg896pZreuo1m24D11IEouTyrSuzsZhNU5zHG9LPcti/ R0+EJvgbhAKNiD8C8nLxgNvL3AQ3I3z4WQMD4dyez8vRH15uU=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
---
Completion/Debian/Command/_apt | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt
index a46c326..d92d2f8 100644
--- a/Completion/Debian/Command/_apt
+++ b/Completion/Debian/Command/_apt
@@ -464,7 +464,11 @@ _apt-get () {
\( \
/$'install\0'\|$'download\0'\|$'source\0'\|$'build-dep\0'/ \
/$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \
- /$'[^\0/]#/'/ /$'[^\0/]#\0'/ ':release name::_apt_releases' \) \| \
+ \( \
+ /$'[^\0/]#/'/ /$'[^\0/]#\0'/ ':release name::_apt_releases' \| \
+ /$'[^\0=]#='/ /$'[^\0=]#\0'/ ':package version::_apt_versions_of_binary_package' \
+ \) \
+ \) \| \
/$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \
/$'dist-upgrade\0'/ \| \
@@ -614,6 +618,41 @@ _apt_releases () {
_tags apt-releases && compadd -a _apt_releases
}
+# Complete versions of the package named in $match[1].
+#
+# Interpret the package name as a binary package (even if there is
+# a source package by that name, too).
+_apt_versions_of_binary_package() {
+ local package_name=${match[1]%=} # $match was set by _regex_arguments
+ local line
+ local name version source
+ local -a kv
+
+ for line in ${(f)"$(_call_program versions-of-package "apt-cache madison $package_name")"}; do
+ # If $package_name is a source package name, we'll have lines of the form
+ # $package_name | $version | ...Sources
+ #
+ # If $package_name is a binary package name, we'll have lines of the form
+ # $package_name | $version | ...Packages
+ # $src_package_name | $version | ...Sources
+ for name version source in "${(@s. | .)line}"; do
+ # Remove leading/trailing whitespace
+ name=${name// }
+ version=${version// }
+ source=${${source# ##}% ##}
+
+ # Skip source packages
+ if [[ $name != $package_name ]] || [[ $source != *Packages* ]]; then
+ continue
+ fi
+
+ kv+=( "${version//:/\\:}:$source" )
+ done
+ done
+
+ _describe -t apt-package-versions "package versions" kv "$@"
+}
+
_apt_caching_policy () {
local -a oldp
Messages sorted by:
Reverse Date,
Date,
Thread,
Author