add bash completion support

This commit is contained in:
Tilman Kranz
2025-05-18 01:18:52 +02:00
parent 3b810ca4d3
commit 2d0adfb7c0
2 changed files with 32 additions and 2 deletions

View File

@ -0,0 +1,22 @@
_pulseaudio_tcp_completions() {
local cur options commands delete
cur=${COMP_WORDS[COMP_CWORD]}
options=( "--debug" "--help" "--nogui" )
commands=( "start" "stop" "status" "setup" "restart" )
for delete in "${COMP_WORDS[@]::${#COMP_WORDS[@]}-1}" ; do
options=("${options[@]/$delete}")
commands=("${commands[@]/$delete}")
done
COMPREPLY=()
case "$cur" in
'') mapfile -t COMPREPLY < <(compgen -W "${options[*]} ${commands[*]}" -- "$cur") ;;
-*) mapfile -t COMPREPLY < <(compgen -W "${options[*]}" -- "$cur") ;;
[^-]*) mapfile -t COMPREPLY < <(compgen -W "${commands[*]}" -- "$cur") ;;
esac
return 0
} && complete -F _pulseaudio_tcp_completions pulseaudio-tcp