[Bash-completion-devel] Bug#640217: bash-completion: complete package versions with apt-get install
Jerome Reybert
jreybert at gmail.com
Sat Sep 3 13:01:34 UTC 2011
Package: bash-completion
Version: 1:1.3-1
Severity: wishlist
Tags: patch
apt-get provides a way to install a given package version:
$ apt-get install package=version
But bash-completion does not handle the completion for these versions. So, if
you do not know the exact version string of your package, you must search it
through apt-cache policy or apt-cache showpkg in a first time.
This patch provides the following behaviour:
$ apt-get install package=<tab>
will propose the existing versions for package.
It currently relies on apt-cache showpkg syntax, which is quite verbose. Maybe
it would be safer to rely on apt-cache policy, or if you know any other way to
get neat list of package versions.
Jérôme
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (750, 'testing'), (700, 'stable'), (600, 'unstable'), (550, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 3.0.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages bash-completion depends on:
ii bash 4.1-3 The GNU Bourne Again SHell
bash-completion recommends no packages.
bash-completion suggests no packages.
-- no debconf information
-------------- next part --------------
--- completions/apt 2011-01-21 10:36:11.000000000 +0100
+++ apt.new 2011-08-31 12:47:37.000000000 +0200
@@ -32,6 +32,17 @@
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
return 0
;;
+ install)
+
+ if [[ $cur =~ =$ ]]; then
+# assume that versions of package are between "Versions:" and "Reverse Depends:" strings in apt-cache showpkg
+ COMPREPLY=( $( apt-cache --no-generate showpkg $prev | awk '/^Versions/ {versions=1}; /^Reverse\ Depends/ {versions=0}; { if (versions == 1 && $1 $1 ~ /^[0-9]/ ) print $1 } ' ) )
+ else
+ COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+ 2> /dev/null ) )
+ fi
+ return 0
+ ;;
*)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
2> /dev/null ) )
More information about the Bash-completion-devel
mailing list