summaryrefslogtreecommitdiff
path: root/contrib/apt
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/apt')
-rw-r--r--contrib/apt32
1 files changed, 17 insertions, 15 deletions
diff --git a/contrib/apt b/contrib/apt
index 36c66c99..4010a0d5 100644
--- a/contrib/apt
+++ b/contrib/apt
@@ -6,8 +6,7 @@ _apt_get()
local cur prev special i
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
+ _get_comp_words_by_ref cur prev
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
if [[ ${COMP_WORDS[i]} == @(install|remove|autoremove|purge|source|build-dep) ]]; then
@@ -27,6 +26,12 @@ _apt_get()
fi
return 0
;;
+ source)
+ COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
+ 2> /dev/null ) $( apt-cache dumpavail | \
+ command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
+ return 0
+ ;;
*)
COMPREPLY=( $( apt-cache --no-generate pkgnames "$cur" \
2> /dev/null ) )
@@ -35,14 +40,14 @@ _apt_get()
esac
fi
- case "$prev" in
- -@(c|-config-file))
+ case $prev in
+ -c|--config-file)
_filedir
return 0
;;
- -@(t|-target-release|-default-release))
+ -t|--target-release|--default-release)
COMPREPLY=( $( apt-cache policy | \
- grep "release.o=Debian,a=$cur" | \
+ command grep "release.o=Debian,a=$cur" | \
sed -e "s/.*a=\(\w*\).*/\1/" | uniq 2> /dev/null) )
return 0
;;
@@ -66,7 +71,7 @@ _apt_get()
return 0
} &&
-complete -F _apt_get $filenames apt-get
+complete -F _apt_get -o filenames apt-get
# Debian apt-cache(8) completion.
#
@@ -76,9 +81,7 @@ _apt_cache()
local cur prev special i
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
+ _get_comp_words_by_ref cur prev
if [ "$cur" != show ]; then
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
@@ -98,8 +101,7 @@ _apt_cache()
showsrc)
COMPREPLY=( $( apt-cache dumpavail | \
- grep "^Source: $cur" | sort | \
- uniq | cut -f2 -d" " ) )
+ command grep "^Source: $cur" | sort -u | cut -f2 -d" " ) )
return 0
;;
@@ -112,8 +114,8 @@ _apt_cache()
fi
- case "$prev" in
- -@(c|p|s|-config-file|-@(pkg|src)-cache))
+ case $prev in
+ -c|-p|-s|--config-file|--pkg-cache|--src-cache)
_filedir
return 0
;;
@@ -144,7 +146,7 @@ _apt_cache()
return 0
} &&
-complete -F _apt_cache $filenames apt-cache
+complete -F _apt_cache -o filenames apt-cache
# Local variables:
# mode: shell-script