aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-05-12 02:57:40 +0200
committerMattias Andrée <maandree@operamail.com>2012-05-12 02:57:40 +0200
commit6b2661f1235534e800a9d3070a73e7c0e6262bfc (patch)
treecf4d8f3180b552efd2fe81a6a86d4f358a3f6c99
parenta3677eae4affbe53430084f95b8d111a1cbd6245 (diff)
downloadponysay-6b2661f1235534e800a9d3070a73e7c0e6262bfc.tar.gz
ponysay-6b2661f1235534e800a9d3070a73e7c0e6262bfc.tar.bz2
ponysay-6b2661f1235534e800a9d3070a73e7c0e6262bfc.zip
completion for bash
-rw-r--r--completion/bash-completion.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh
new file mode 100644
index 0000000..31daef2
--- /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/ponies/
+ usrponies=~/.ponies/
+ if [[ $TERM = "linux" ]]; then
+ sysponies=/usr/share/ttyponies/
+ usrponies=~/.ttyponies/
+ fi
+
+ if [[ -d $sysponies ]]; then
+ COMPREPLY+=( $( compgen -W "$(ls $sysponies | sed -e 's/.pony//g')" -- "$cur" ) )
+ fi
+ if [[ -d $usrponies ]]; then
+ COMPREPLY+=( $( compgen -W "$(ls $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
+