2010-07-04 17:48:09 +04:00
|
|
|
# bash completion for various Slackware specific tools
|
|
|
|
|
|
|
|
have rpm2tgz && [ -f /etc/slackware-version ] &&
|
|
|
|
_rpm2tgz()
|
|
|
|
{
|
|
|
|
COMPREPLY=()
|
|
|
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '-s -S -n -r -d' -- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
COMPREPLY=( $(compgen -f -X "!*.rpm" -- "$cur") )
|
|
|
|
} && complete -F _rpm2tgz -o plusdirs rpm2tgz rpm2targz
|
2010-07-05 02:08:42 +04:00
|
|
|
|
|
|
|
have slapt-get && [ -f /etc/slackware-version ] &&
|
|
|
|
_slapt-get()
|
|
|
|
{
|
|
|
|
COMPREPLY=()
|
|
|
|
local cur prev
|
|
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '--download-only -d --simulate -s \
|
|
|
|
--no-prompt -y --prompt -p --reinstall --ignore-excludes \
|
|
|
|
--no-md5 --ignore-dep --no-dep --print-uris --show-stats -S \
|
|
|
|
--config -c --remove-obsolete --retry --no-upgrade \
|
|
|
|
--update -u --upgrade --dist-upgrade --install -i --install-set \
|
|
|
|
--remove --show --filelist --search --list --available \
|
2010-07-05 19:15:53 +04:00
|
|
|
--installed --clean --autoclean --add-keys \
|
|
|
|
--version --help -h' -- "$cur" ) )
|
2010-07-05 02:08:42 +04:00
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
case $prev in
|
|
|
|
--config|-c)
|
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
--retry|--search)
|
|
|
|
# argument required but no completions available
|
|
|
|
return 0
|
|
|
|
;;
|
2010-07-05 04:23:23 +04:00
|
|
|
esac
|
|
|
|
|
|
|
|
local words t
|
|
|
|
_get_comp_words_by_ref words
|
|
|
|
|
|
|
|
# search for last action (--install|--install-set|--remove|--show|--filelist)
|
|
|
|
for (( i=${#words[@]}-1; i>0; i-- )); do
|
2010-07-09 21:46:43 +04:00
|
|
|
if [[ ${words[i]} == -@(i|-install|-show) ]]; then
|
2010-07-05 04:23:23 +04:00
|
|
|
t="all"
|
|
|
|
break
|
|
|
|
elif [[ ${words[i]} == --install-set ]]; then
|
|
|
|
t="set"
|
|
|
|
break
|
2010-07-09 21:46:43 +04:00
|
|
|
elif [[ ${words[i]} == --@(remove|filelist) ]]; then
|
2010-07-05 04:23:23 +04:00
|
|
|
t="ins"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
case $t in
|
2010-07-09 21:46:43 +04:00
|
|
|
all) # --install|-i|--show
|
2010-07-05 13:40:39 +04:00
|
|
|
# slapt-get will fail to search for "^orc-0.4.4" for example
|
|
|
|
# it can only search for names, so we should anything else
|
|
|
|
local name=$( echo $cur | cut -f1 -d- )
|
|
|
|
COMPREPLY=( $( slapt-get --search "^$name" 2> /dev/null | \
|
|
|
|
awk '{print $1}' | grep "^$cur" ) )
|
2010-07-05 02:08:42 +04:00
|
|
|
return 0
|
|
|
|
;;
|
2010-07-09 21:46:43 +04:00
|
|
|
ins) # --remove|--filelist
|
2010-07-05 04:23:23 +04:00
|
|
|
COMPREPLY=( $( (cd /var/log/packages; compgen -f -- "$cur") ) )
|
2010-07-05 02:08:42 +04:00
|
|
|
return 0
|
|
|
|
;;
|
2010-07-05 19:15:53 +04:00
|
|
|
set) # --install-set
|
2010-07-05 04:23:23 +04:00
|
|
|
COMPREPLY=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x \
|
|
|
|
xap y' -- "$cur" ) )
|
2010-07-05 02:08:42 +04:00
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
} && complete -F _slapt-get slapt-get
|