completion supports multiple commands

This commit is contained in:
Tilman Kranz 2025-06-01 15:43:26 +02:00
parent f08b857aff
commit 03e3953eb8

View file

@ -1,7 +1,6 @@
_pulseaudio_tcp_completions() {
local \
command_list \
command_pattern \
commands \
cur \
option_list \
@ -21,20 +20,8 @@ _pulseaudio_tcp_completions() {
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
"$more_options" && option_list="${options[*]}"
command_list="${commands[*]}"
mapfile -t COMPREPLY < <( compgen -W "$option_list $command_list" -- "$cur")