code cleanup of completion logic
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user