[pulseaudio-discuss] [PATCH 2/3] zsh-completion: Fix pacat device completion
poljar (Damir Jelić)
poljarinho at gmail.com
Thu Aug 15 05:08:43 PDT 2013
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(-)
diff --git a/shell-completion/pulseaudio-zsh-completion.zsh b/shell-completion/pulseaudio-zsh-completion.zsh
index 142d031..e872736 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
--
1.8.3.4
More information about the pulseaudio-discuss
mailing list