ponysay/completion/bash-completion.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2012-05-12 02:57:40 +02:00
# bash completion for ponysay -*- shell-script -*-
_ponysay()
{
local cur prev words cword
_init_completion -n = || return
quotes=$(pq4ps --list 2>/dev/null)
quotesexit=$?
options='-v -h -l -f -W'
if [[ $quotesexit = 0 ]]; then
options="$options -q"
fi
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
2012-05-12 02:57:40 +02:00
if [[ $prev = "-f" ]]; then
COMPREPLY=()
sysponies=/usr/share/ponysay/ponies/
2012-07-19 18:26:19 +02:00
usrponies=~/.local/share/ponysay/ponies/
2012-05-12 02:57:40 +02:00
if [[ $TERM = "linux" ]]; then
sysponies=/usr/share/ponysay/ttyponies/
2012-07-19 18:26:19 +02:00
usrponies=~/.local/share/ponysay/ttyponies/
2012-05-12 02:57:40 +02:00
fi
if [[ -d $sysponies ]]; then
2012-07-15 01:15:58 +02:00
COMPREPLY+=( $( compgen -W "$(ls --color=no $sysponies | sed -e 's/.pony//g')" -- "$cur" ) )
2012-05-12 02:57:40 +02:00
fi
if [[ -d $usrponies ]]; then
2012-07-15 01:15:58 +02:00
COMPREPLY+=( $( compgen -W "$(ls --color=no $usrponies | sed -e 's/.pony//g')" -- "$cur" ) )
2012-05-12 02:57:40 +02:00
fi
elif [[ $prev = "-W" ]]; then
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
elif [[ $quotesexit = 0 ]] && [[ $prev = "-q" ]]; then
COMPREPLY=( $( compgen -W "$quotes" -- "$cur" ) )
2012-05-12 02:57:40 +02:00
fi
}
complete -o default -F _ponysay ponysay