29 lines
786 B
Plaintext
29 lines
786 B
Plaintext
_pulseaudio_tcp_completions() {
|
|
local options commands cur delete all_options command_pattern all_commands
|
|
|
|
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}")
|
|
done
|
|
|
|
all_options="${options[*]}"
|
|
|
|
printf -v command_pattern "%s|" "${commands[@]}"
|
|
command_pattern="(${command_pattern%?})"
|
|
|
|
if [[ ${COMP_WORDS[*]} =~ $command_pattern ]] ; then
|
|
all_commands=""
|
|
else
|
|
all_commands="${commands[*]}"
|
|
fi
|
|
|
|
mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" "$cur")
|
|
|
|
return 0
|
|
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp
|