Files
pulseaudio-tcp/pulseaudio-tcp.bash_completion
2025-05-18 15:39:50 +02:00

41 lines
866 B
Bash

_pulseaudio_tcp_completions() {
local \
command_list \
command_pattern \
commands \
cur \
option_list \
options \
word
options=( "--debug" "--help" "--nogui" )
commands=( "start" "stop" "status" "setup" "restart" )
cur=${COMP_WORDS[COMP_CWORD]}
for word in "${COMP_WORDS[@]}" ; do
[[ $word = "$cur" ]] && continue
options=("${options[@]/$word}")
commands=("${commands[@]/$word}")
done
option_list="${options[*]}"
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