completion suggests only one command verb
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
_pulseaudio_tcp_completions() {
|
_pulseaudio_tcp_completions() {
|
||||||
local cur options commands delete
|
local cur options commands delete no_cmd
|
||||||
|
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
options=( "--debug" "--help" "--nogui" )
|
options=( "--debug" "--help" "--nogui" )
|
||||||
@ -10,12 +10,23 @@ _pulseaudio_tcp_completions() {
|
|||||||
commands=("${commands[@]/$delete}")
|
commands=("${commands[@]/$delete}")
|
||||||
done
|
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
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
|
||||||
case "$cur" in
|
case "$cur" in
|
||||||
'') mapfile -t COMPREPLY < <(compgen -W "${options[*]} ${commands[*]}" -- "$cur") ;;
|
'') mapfile -t COMPREPLY < <(compgen -W "$all_options $all_commands" -- "$cur") ;;
|
||||||
-*) mapfile -t COMPREPLY < <(compgen -W "${options[*]}" -- "$cur") ;;
|
-*) mapfile -t COMPREPLY < <(compgen -W "$all_options" -- "$cur") ;;
|
||||||
[^-]*) mapfile -t COMPREPLY < <(compgen -W "${commands[*]}" -- "$cur") ;;
|
[^-]*) mapfile -t COMPREPLY < <(compgen -W "$all_commands" -- "$cur") ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
Reference in New Issue
Block a user