_pulseaudio_tcp_completions() { local \ command_list \ commands \ cur \ option_list \ options \ word options=( "--debug" "--help" "--no-gui" "--" ) commands=( "start" "stop" "status" "setup" "restart" ) cur=${COMP_WORDS[COMP_CWORD]} more_options=true for word in "${COMP_WORDS[@]}" ; do [[ $word = "$cur" ]] && continue [[ $word = -- ]] && more_options=false options=("${options[@]/$word}") commands=("${commands[@]/$word}") done "$more_options" && option_list="${options[*]}" command_list="${commands[*]}" mapfile -t COMPREPLY < <( compgen -W "$option_list $command_list" -- "$cur") return 0 } complete -F _pulseaudio_tcp_completions pulseaudio-tcp # vim:et ft=bash sw=2 ts=2