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
|
#
# Bash command line completion for rinse
#
function _rinse()
{
local cur prev opts vgs
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Determine arguments dynamically. Avoids out-of-dateness.
opts=$(rinse --help|grep -- --|awk '{print $1}'|grep -- -- | sort -u)
case "$prev" in
--arch)
COMPREPLY=( $( compgen -W 'amd64 i386' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--cache)
COMPREPLY=( $( compgen -W '0 1' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
--distribution)
dists=$(for x in `ls -1 /etc/rinse/*.conf 2>/dev/null`; do i=`basename $x`; echo ${i/.conf/} ; done )
COMPREPLY=( $( compgen -W '${dists}' -- "${COMP_WORDS[COMP_CWORD]}" ) )
return 0
;;
esac
if [[ ${cur} == -* ]]; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _rinse rinse
|