# bash completion for ArchLinux rc.d # have rc.d && _rc.d() { local cur prev COMPREPLY=() _get_comp_words_by_ref cur prev case $COMP_CWORD in 1) COMPREPLY=( $(compgen -W "help list start stop restart" -- "$cur") ) ;; 2) case "$prev" in stop | restart) COMPREPLY=( $(compgen -W "$(rc.d list | grep 'STARTED' | sed 's+^\[.*\] ++g' )" -- "$cur") ) ;; start) COMPREPLY=( $(compgen -W "$(rc.d list | grep 'STOPPED' | sed 's+^\[.*\] ++g' )" -- "$cur") ) ;; esac ;; esac return 0 } && complete -F _rc.d rc.d