fix some inconsistencies
- the currently edited word should be omitted when removing duplicate completion suggestions, which is not necessarily the last word - when using "compgen", mark "$cur" as non-option argument - some formatting cleanup
This commit is contained in:
@ -1,12 +1,20 @@
|
|||||||
_pulseaudio_tcp_completions() {
|
_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" )
|
options=( "--debug" "--help" "--nogui" )
|
||||||
commands=( "start" "stop" "status" "setup" "restart" )
|
commands=( "start" "stop" "status" "setup" "restart" )
|
||||||
|
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
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}")
|
options=("${options[@]/$delete}")
|
||||||
commands=("${commands[@]/$delete}")
|
commands=("${commands[@]/$delete}")
|
||||||
done
|
done
|
||||||
@ -22,7 +30,15 @@ _pulseaudio_tcp_completions() {
|
|||||||
all_commands="${commands[*]}"
|
all_commands="${commands[*]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" "$cur")
|
mapfile -t COMPREPLY < <(
|
||||||
|
compgen \
|
||||||
|
-W "$all_options $all_commands" \
|
||||||
|
-- "$cur"
|
||||||
|
)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|
}
|
||||||
|
|
||||||
|
complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|
||||||
|
|
||||||
|
# vim:et ft=bash sw=2 ts=2
|
||||||
|
Reference in New Issue
Block a user