_pulseaudio_tcp_completions() { local cur options commands delete cur=${COMP_WORDS[COMP_CWORD]} options=( "--debug" "--help" "--nogui" ) commands=( "start" "stop" "status" "setup" "restart" ) for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do options=("${options[@]/$delete}") commands=("${commands[@]/$delete}") done COMPREPLY=() case "$cur" in '') mapfile -t COMPREPLY < <(compgen -W "${options[*]} ${commands[*]}" -- "$cur") ;; -*) mapfile -t COMPREPLY < <(compgen -W "${options[*]}" -- "$cur") ;; [^-]*) mapfile -t COMPREPLY < <(compgen -W "${commands[*]}" -- "$cur") ;; esac return 0 } && complete -F _pulseaudio_tcp_completions pulseaudio-tcp