aboutsummaryrefslogtreecommitdiff
path: root/completion
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-07-17 01:07:47 +0200
committerMattias Andrée <maandree@operamail.com>2012-07-17 01:07:47 +0200
commit3c888482e41a7c744c8c35e31f49fd63246caa44 (patch)
tree733e3bb93c9435fda5cd25442df2f25be01a9e4a /completion
parent68d1b029712a62a11faa515e9b0303477d1d3ca7 (diff)
parent8c986f062a12064234cd27d143d4e967ff4aba06 (diff)
downloadponysay-3c888482e41a7c744c8c35e31f49fd63246caa44.tar.gz
ponysay-3c888482e41a7c744c8c35e31f49fd63246caa44.tar.bz2
ponysay-3c888482e41a7c744c8c35e31f49fd63246caa44.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'completion')
-rw-r--r--completion/bash-completion.sh33
-rw-r--r--completion/zsh-completion.zsh11
2 files changed, 44 insertions, 0 deletions
diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh
new file mode 100644
index 0000000..82eb608
--- /dev/null
+++ b/completion/bash-completion.sh
@@ -0,0 +1,33 @@
+# bash completion for ponysay -*- shell-script -*-
+
+_ponysay()
+{
+ local cur prev words cword
+ _init_completion -n = || return
+
+ COMPREPLY=( $( compgen -W '-v -h -l -f -W' -- "$cur" ) )
+
+ if [[ $prev = "-f" ]]; then
+ COMPREPLY=()
+
+ sysponies=/usr/share/ponysay/ponies/
+ usrponies=~/.ponies/
+ if [[ $TERM = "linux" ]]; then
+ sysponies=/usr/share/ponysay/ttyponies/
+ usrponies=~/.ttyponies/
+ fi
+
+ if [[ -d $sysponies ]]; then
+ COMPREPLY+=( $( compgen -W "$(ls --color=no $sysponies | sed -e 's/.pony//g')" -- "$cur" ) )
+ fi
+ if [[ -d $usrponies ]]; then
+ COMPREPLY+=( $( compgen -W "$(ls --color=no $usrponies | sed -e 's/.pony//g')" -- "$cur" ) )
+ fi
+ elif [[ $prev = "-W" ]]; then
+ cols=$( echo `tput cols` - 10 | bc )
+ COMPREPLY=( $cols $( echo $cols / 2 | bc ) 100 60 )
+ fi
+}
+
+complete -o default -F _ponysay ponysay
+
diff --git a/completion/zsh-completion.zsh b/completion/zsh-completion.zsh
new file mode 100644
index 0000000..07b2ebf
--- /dev/null
+++ b/completion/zsh-completion.zsh
@@ -0,0 +1,11 @@
+#compdef ponysay
+_shortopts=(
+ '-v[Show version and exit]'
+ '-h[Show this help and exit]'
+ '-l[list ponyfiles]'
+ '-f[Select a pony (either a filename or a ponyname]: :_path_files -W "/usr/share/ponysay/ponies" -g "*(\:r)"'
+ '-W[The screen column where the message should be wrapped]'
+ )
+_arguments -s : \
+ "$_shortopts[@]"
+