diff --git a/pulseaudio-tcp.bash_completion b/pulseaudio-tcp.bash_completion index 1d8a60c..2b18a1e 100644 --- a/pulseaudio-tcp.bash_completion +++ b/pulseaudio-tcp.bash_completion @@ -1,10 +1,11 @@ _pulseaudio_tcp_completions() { - local cur options commands delete all_options command_pattern all_commands + local options commands cur delete all_options command_pattern all_commands - cur=${COMP_WORDS[COMP_CWORD]} options=( "--debug" "--help" "--nogui" ) commands=( "start" "stop" "status" "setup" "restart" ) + cur=${COMP_WORDS[COMP_CWORD]} + for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do options=("${options[@]/$delete}") commands=("${commands[@]/$delete}") @@ -21,13 +22,7 @@ _pulseaudio_tcp_completions() { all_commands="${commands[*]}" fi - COMPREPLY=() - - case "$cur" in - '') mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" -- "$cur") ;; - -*) mapfile -t COMPREPLY < <(compgen -W "$all_options" -- "$cur") ;; - [^-]*) mapfile -t COMPREPLY < <(compgen -W "$all_commands" -- "$cur") ;; - esac + mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" "$cur") return 0 } && complete -F _pulseaudio_tcp_completions pulseaudio-tcp