rabbitmq-server/scripts/rabbitmqctl-autocomplete.sh

24 lines
819 B
Bash
Raw Normal View History

if which rabbitmqctl > /dev/null; then
2017-01-17 01:57:42 +08:00
if [ -n "$BASH_VERSION" ]; then
_rabbitmqctl_complete() {
COMPREPLY=()
local LANG=en_US.UTF-8
2017-01-17 01:57:42 +08:00
local word="${COMP_WORDS[COMP_CWORD]}"
local completions="$(/usr/lib/rabbitmq/bin/rabbitmqctl --auto-complete $COMP_LINE)"
2017-01-17 01:57:42 +08:00
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
}
complete -f -F _rabbitmqctl_complete rabbitmqctl
elif [ -n "$ZSH_VERSION" ]; then
_rabbitmqctl_complete() {
local word completions a
local LANG=en_US.UTF-8
2017-01-17 01:57:42 +08:00
read -cl a
word="$1"
completions="$(/usr/lib/rabbitmq/bin/rabbitmqctl --auto-complete ${a})"
2017-01-17 01:57:42 +08:00
reply=( "${(ps:\n:)completions}" )
}
compctl -f -K _rabbitmqctl_complete rabbitmqctl
fi
fi