aboutsummaryrefslogtreecommitdiff
path: root/completion
diff options
context:
space:
mode:
authorjaseg <s@jaseg.de>2013-04-03 15:41:21 +0200
committerjaseg <s@jaseg.de>2013-04-03 15:41:21 +0200
commita41e8b36a184c67c941e349e0ce1af123c847bac (patch)
treee43c7bbf19a2a8d09793fa15eefbfcfa1e55f957 /completion
parentcccea7324cd692e7926595d9c1a248602c027067 (diff)
downloadponysay-a41e8b36a184c67c941e349e0ce1af123c847bac.tar.gz
ponysay-a41e8b36a184c67c941e349e0ce1af123c847bac.tar.bz2
ponysay-a41e8b36a184c67c941e349e0ce1af123c847bac.zip
Fixed -* list args, bash completion, zsh balloon completion
Diffstat (limited to 'completion')
-rwxr-xr-xcompletion/bash-completion.sh42
-rw-r--r--completion/zsh-completion.sh7
2 files changed, 33 insertions, 16 deletions
diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh
index 6a346f5..f5284cf 100755
--- a/completion/bash-completion.sh
+++ b/completion/bash-completion.sh
@@ -1,21 +1,35 @@
-#!bash
-#
-# this is bash completion function file for ponysay.py.
-# generated by genzshcomp(ver: 0.5.1)
-#
+#!/usr/bin/env bash
-_ponysay.py()
+_ponysay()
{
- local cur
- local cmd
+ local cur prev
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
- cur=${COMP_WORDS[$COMP_CWORD]}
- cmd=( ${COMP_WORDS[@]} )
+ declare -ga _ponysay_ponies _ponysay_balloons _ponythink_balloons
+ [[ 0 < "${#_ponysay_ponies}" ]] || _ponysay_ponies=( $(ponysay -p list) )
+ [[ 0 < "${#_ponysay_balloons}" ]] || _ponysay_balloons=( $(ponysay -b list) )
+ [[ 0 < "${#_ponythink_balloons}" ]] || _ponythink_balloons=( $(ponythink -b list) )
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $( compgen -W "-h --help --pony -p --quote -q --center -c --center-text -C --width -w --balloon -b" -- $cur ) )
- return 0
+ if [[ "$cur" = -* ]]
+ then COMPREPLY=( $( compgen -W "-h --help --pony -p --quote -q --center -c --center-text -C --width -w --balloon -b" -- "$cur" ) )
+ return 0
+ fi
+
+ if [[ "$prev" =~ -[^-]*p$ || "$prev" = "--pony" ]]
+ then COMPREPLY=( $( compgen -W "${_ponysay_ponies[*]}" -- "$cur" ) )
+ return 0
+ fi
+
+ if [[ "$prev" =~ -[^-]*b$ || "$prev" = "--balloon" ]]
+ then
+ if [[ "$COMP_LINE" == ponythink* ]]
+ then COMPREPLY=( $( compgen -W "${_ponythink_balloons[*]}" -- "$cur" ) )
+ else COMPREPLY=( $( compgen -W "${_ponysay_balloons[*]}" -- "$cur" ) )
+ fi
+ return 0
fi
}
-complete -F _ponysay.py -o default ponysay.py
+complete -F _ponysay -o default ponysay
+complete -F _ponysay -o default ponythink
diff --git a/completion/zsh-completion.sh b/completion/zsh-completion.sh
index 4e280ba..917c918 100644
--- a/completion/zsh-completion.sh
+++ b/completion/zsh-completion.sh
@@ -14,8 +14,11 @@ local -a _available_ponies
compadd "$@" -a _available_ponies
}
-_ponysay_balloons(){
- [[ "$words" == ponythink* ]] && compadd "$@" cowsay ascii || compadd "$@" cowsay ascii unicode round linux-vt
+local -a _ponysay_balloons _ponythink_balloons
+(( $+functions[_ponysay_pony] )) || _ponysay_balloons(){
+ (( $#_ponysay_balloons )) || _ponysay_balloons=($(ponysay -b list))
+ (( $#_ponythink_balloons )) || _ponythink_balloons=($(ponythink -b list))
+ [[ "$words" == ponythink* ]] && compadd "$@" -a _ponythink_balloons || compadd "$@" -a _ponysay_balloons
}
_arguments -s -w -S \