1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
From: Ville Skyttä <ville.skytta@iki.fi>
Subject: apt-get: Complete install package=versions
Origin: upstream, https://github.com/scop/bash-completion/commit/c664b07ac98bf46c0ea416161cef0a0dbe11ab50.patch
Bug-Debian: https://bugs.debian.org/640217
---
completions/apt-get | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/completions/apt-get b/completions/apt-get
index 32c4bcf8..df4a3d0b 100644
--- a/completions/apt-get
+++ b/completions/apt-get
@@ -3,7 +3,7 @@
_apt_get()
{
local cur prev words cword
- _init_completion || return
+ _init_completion -n = || return
local special i
for (( i=0; i < ${#words[@]}-1; i++ )); do
@@ -29,13 +29,22 @@ _apt_get()
2> /dev/null ) $( apt-cache dumpavail | \
command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
;;
- *)
- if [[ $special == install && $cur == */* ]]; then
+ install)
+ if [[ $cur == */* ]]; then
_filedir deb
- else
- COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
- 2>/dev/null ) )
+ return
+ elif [[ $cur == *=* ]]; then
+ COMPREPLY=( $( compgen -W "$( \
+ apt-cache --no-generate show "${cur%%=*}" 2>/dev/null |
+ command sed -ne \
+ 's/^Version:[[:space:]]*\([^[:space:]]\)/\1/p' )" \
+ -- "${cur#*=}" ) )
+ return
fi
+ ;;&
+ *)
+ COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+ 2>/dev/null ) )
;;
esac
return
--
2.16.2
|