[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.3-364-gd44aaed
Igor Murzov
e-mail at date.by
Sun Jun 12 14:52:19 UTC 2011
The following commit has been merged in the master branch:
commit 1f506187158363f6cebbcddc8deb79358b2d723b
Author: Igor Murzov <e-mail at date.by>
Date: Sun Jun 12 18:03:08 2011 +0400
slapt-get: Respect settings supplied by --config option.
Also complete only available packages as argument to --install option.
diff --git a/completions/slapt b/completions/slapt
index 3a7514d..beaaff0 100644
--- a/completions/slapt
+++ b/completions/slapt
@@ -32,9 +32,12 @@ _slapt_get()
local i t
# search for last action (--install|--install-set|--remove|--show|--filelist)
for (( i=${#words[@]}-1; i>0; i-- )); do
- if [[ ${words[i]} == -@(i|-install|-show) ]]; then
+ if [[ ${words[i]} == --show ]]; then
t="all"
break
+ elif [[ ${words[i]} == -@(i|-install) ]]; then
+ t="avl"
+ break
elif [[ ${words[i]} == --install-set ]]; then
t="set"
break
@@ -44,15 +47,32 @@ _slapt_get()
fi
done
+ local config="/etc/slapt-get/slapt-getrc" # default config location
+ # search for config
+ for (( i=${#words[@]}-1; i>0; i-- )); do
+ if [[ ${words[i]} == -@(c|-config) ]]; then
+ config="${words[i+1]}"
+ break
+ fi
+ done
+ if [ ! -r "$config" ]; then
+ return
+ fi
+
case $t in
- all) # --install|-i|--show
+ all) # --show
# slapt-get will fail to search for "^name-version"
# it can search for names only
- local name=$( echo $cur | cut -f1 -d- )
- COMPREPLY=( $( slapt-get --search "^$name" 2> /dev/null | \
+ local name=${cur%%-*}
+ COMPREPLY=( $( slapt-get -c $config --search "^$name" 2>/dev/null |\
sed -ne "/^$cur/{s/ .*$//;p}" ) )
return 0
;;
+ avl) # --install|-i|
+ COMPREPLY=( $( slapt-get -c $config --available 2>/dev/null | \
+ sed -ne "/^$cur/{s/ .*$//;p}") )
+ return 0
+ ;;
ins) # --remove|--filelist
COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
return 0
--
bash-completion
More information about the Bash-completion-commits
mailing list