mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-22 04:27:58 +01:00
completion for bash
This commit is contained in:
parent
a3677eae4a
commit
6b2661f123
1 changed files with 33 additions and 0 deletions
33
completion/bash-completion.sh
Normal file
33
completion/bash-completion.sh
Normal file
|
@ -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
|
||||
|
Loading…
Reference in a new issue