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.
This commit is contained in:
poljar (Damir Jelić) 2013-08-15 14:08:43 +02:00 committed by Tanu Kaskinen
parent 47729c43b4
commit b49298c51e

View file

@ -24,18 +24,34 @@ _devices() {
esac esac
elif [[ $service == (pacat|paplay|parecord) ]]; then elif [[ $service == (pacat|paplay|parecord) ]]; then
if [[ $words == *-r[[:space:]]* ]]; then case $words[$((CURRENT))] in
cmd=('sources') --device=*)
elif [[ $words == *-p[[:space:]]* ]]; then if [[ $words == *(--playback|-p)[[:space:]]* ||
cmd=('sinks') $service == paplay ]]; then
else cmd=('sinks')
cmd=('sinks' 'sources') elif [[ $words == *(--record|-r)[[:space:]]* ||
fi $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 fi
for (( i = 0; i < ${#words[@]}; i++ )) do for (( i = 0; i < ${#words[@]}; i++ )) do