pulseaudio-tcp/pulseaudio-tcp.bash_completion
2025-05-25 06:47:35 +02:00

46 lines
996 B
Bash

_pulseaudio_tcp_completions() {
local \
command_list \
command_pattern \
commands \
cur \
option_list \
options \
word
options=( "--debug" "--help" "--no-gui" "--" )
commands=( "start" "stop" "status" "setup" "restart" )
cur=${COMP_WORDS[COMP_CWORD]}
more_options=true
for word in "${COMP_WORDS[@]}" ; do
[[ $word = "$cur" ]] && continue
[[ $word = -- ]] && more_options=false
options=("${options[@]/$word}")
commands=("${commands[@]/$word}")
done
if "$more_options" ; then
option_list="${options[*]}"
else
option_list=""
fi
printf -v command_pattern "%s|" "${commands[@]}"
command_pattern="(${command_pattern%?})"
if [[ ${COMP_WORDS[*]} =~ $command_pattern ]] ; then
command_list=""
else
command_list="${commands[*]}"
fi
mapfile -t COMPREPLY < <( compgen -W "$option_list $command_list" -- "$cur")
return 0
}
complete -F _pulseaudio_tcp_completions pulseaudio-tcp
# vim:et ft=bash sw=2 ts=2