From b49298c51ee2fe45ea2556b749ad0952f7580e7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?poljar=20=28Damir=20Jeli=C4=87=29?= Date: Thu, 15 Aug 2013 14:08:43 +0200 Subject: [PATCH] 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. --- .../pulseaudio-zsh-completion.zsh | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh index 142d0314..e872736f 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 -- 2.39.2