diff --git a/pulseaudio-tcp.bash_completion b/pulseaudio-tcp.bash_completion index 2b18a1e..18f95eb 100644 --- a/pulseaudio-tcp.bash_completion +++ b/pulseaudio-tcp.bash_completion @@ -1,12 +1,20 @@ _pulseaudio_tcp_completions() { - local options commands cur delete all_options command_pattern all_commands + local \ + all_commands \ + all_options \ + command_pattern \ + commands \ + cur \ + delete \ + options options=( "--debug" "--help" "--nogui" ) commands=( "start" "stop" "status" "setup" "restart" ) cur=${COMP_WORDS[COMP_CWORD]} - for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do + for delete in "${COMP_WORDS[@]}" ; do + [[ $delete = "$cur" ]] && continue options=("${options[@]/$delete}") commands=("${commands[@]/$delete}") done @@ -22,7 +30,15 @@ _pulseaudio_tcp_completions() { all_commands="${commands[*]}" fi - mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" "$cur") + mapfile -t COMPREPLY < <( + compgen \ + -W "$all_options $all_commands" \ + -- "$cur" + ) return 0 -} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp +} + +complete -F _pulseaudio_tcp_completions pulseaudio-tcp + +# vim:et ft=bash sw=2 ts=2