From b49298c51ee2fe45ea2556b749ad0952f7580e7c Mon Sep 17 00:00:00 2001 From: "poljar (Damir Jelić)" Date: Thu, 15 Aug 2013 14:08:43 +0200 Subject: zsh-completion: Fix pacat device completion The pacat completion didn't complete the right devices for the --record and --playback flags. This patch fixes this and makes the device completion for pacat easily expandable. --- shell-completion/pulseaudio-zsh-completion.zsh | 38 ++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'shell-completion') diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh index 142d0314d..e872736f3 100644 --- a/shell-completion/pulseaudio-zsh-completion.zsh +++ b/shell-completion/pulseaudio-zsh-completion.zsh @@ -24,18 +24,34 @@ _devices() { esac elif [[ $service == (pacat|paplay|parecord) ]]; then - if [[ $words == *-r[[:space:]]* ]]; then - cmd=('sources') - elif [[ $words == *-p[[:space:]]* ]]; then - cmd=('sinks') - else - cmd=('sinks' 'sources') - fi + case $words[$((CURRENT))] in + --device=*) + if [[ $words == *(--playback|-p)[[:space:]]* || + $service == paplay ]]; then + cmd=('sinks') + elif [[ $words == *(--record|-r)[[:space:]]* || + $service == parecord ]]; then + cmd=('sources') + else + cmd=('sinks' 'sources') + fi + ;; + esac + + case $words[$((CURRENT - 1))] in + -d) + if [[ $words == *(--playback|-p)[[:space:]]* || + $service == paplay ]]; then + cmd=('sinks') + elif [[ $words == *(--record|-r)[[:space:]]* || + $service == parecord ]]; then + cmd=('sources') + else + cmd=('sinks' 'sources') + fi + ;; + esac - elif [[ $service == paplay ]]; then - cmd=('sinks') - elif [[ $service == parecord ]]; then - cmd=('sources') fi for (( i = 0; i < ${#words[@]}; i++ )) do -- cgit v1.2.3