aboutsummaryrefslogtreecommitdiff
path: root/completion/bash-completion.sh
blob: 31daef2d86822e0f0144da1e0ec8266c4734410c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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