# # RabbitMQ Server Completion # # Author: Stefan Wold # # Turn on extended globbing shopt -s extglob __rabbitmqctl_list_all_commands () { while read line; do echo $line done < <(rabbitmqctl | awk '/^[[:space:]]+[a-z]+/{ print $1}') } __rabbitmqctl_all_commands= __rabbitmqctl_compute_all_commands () { : ${__rabbitmqctl_all_commands:=$(__rabbitmqctl_list_all_commands)} } # rabbitmqctl(1) completion _rabbitmqctl () { local current previous __rabbitmqctl_compute_all_commands COMPREPLY=() current=${COMP_WORDS[COMP_CWORD]} previous=${COMP_WORDS[COMP_CWORD-1]} if [ $COMP_CWORD -eq 1 ] || [ "${previous:0:1}" = "-" ]; then COMPREPLY=($(compgen -W "${__rabbitmqctl_all_commands}" $current)) else COMPREPLY=($(compgen -f $current)) fi return 0 } complete -F _rabbitmqctl rabbitmqctl