# bash programmable completion for service by # Pedro Pinto (pnboy~AT~pinguix.com) # complete_service() { cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ]; then arg=$arg" start stop restart list" COMPREPLY=( $( compgen -W "${arg}" -- $cur ) ) elif [ $COMP_CWORD -eq 2 ]; then if [ ! $prev == "list" ]; then arg=$( /usr/bin/ls /etc/rc.d/rc.* |sed -e 's|/etc/rc.d/rc.||' | grep -v ".conf" 2> /dev/nul) COMPREPLY=( $( compgen -W "${arg}" -- $cur ) ) fi fi return 0 } complete -F complete_service -o default service