2012-05-12 00:57:40 +00:00
|
|
|
# bash completion for ponysay -*- shell-script -*-
|
|
|
|
|
|
|
|
_ponysay()
|
|
|
|
{
|
|
|
|
local cur prev words cword
|
|
|
|
_init_completion -n = || return
|
|
|
|
|
2012-08-16 16:36:52 +00:00
|
|
|
options='-v -h -l -f -W -q'
|
2012-07-19 02:32:35 +00:00
|
|
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
2012-05-12 00:57:40 +00:00
|
|
|
|
2012-08-18 00:34:54 +00:00
|
|
|
if [ $prev = "-f" ]; then
|
2012-05-12 00:57:40 +00:00
|
|
|
COMPREPLY=()
|
|
|
|
|
2012-07-05 03:30:29 +00:00
|
|
|
sysponies=/usr/share/ponysay/ponies/
|
2012-07-19 16:26:19 +00:00
|
|
|
usrponies=~/.local/share/ponysay/ponies/
|
2012-05-12 00:57:40 +00:00
|
|
|
if [[ $TERM = "linux" ]]; then
|
2012-07-05 03:30:29 +00:00
|
|
|
sysponies=/usr/share/ponysay/ttyponies/
|
2012-07-19 16:26:19 +00:00
|
|
|
usrponies=~/.local/share/ponysay/ttyponies/
|
2012-05-12 00:57:40 +00:00
|
|
|
fi
|
|
|
|
|
2012-08-18 00:34:54 +00:00
|
|
|
[ -d $sysponies ] && COMPREPLY+=( $( compgen -W "$(ls --color=no $sysponies | sed -e 's/.pony//g')" -- "$cur" ) )
|
|
|
|
[ -d $usrponies ] && COMPREPLY+=( $( compgen -W "$(ls --color=no $usrponies | sed -e 's/.pony//g')" -- "$cur" ) )
|
|
|
|
|
|
|
|
elif [ $prev = "-W" ]; then
|
2012-07-19 02:32:35 +00:00
|
|
|
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
|
|
|
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
|
2012-08-18 00:34:54 +00:00
|
|
|
|
|
|
|
elif [ $prev = "-q" ]; then
|
|
|
|
qcmd=/usr/lib/ponysay/pq4ps
|
|
|
|
quoters=$($qcmd -l)
|
|
|
|
COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) )
|
|
|
|
|
2012-05-12 00:57:40 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -o default -F _ponysay ponysay
|
|
|
|
|