simplier completion
This commit is contained in:
parent
c4f07a8b00
commit
dce179f8a3
2 changed files with 11 additions and 44 deletions
|
|
@ -8,28 +8,18 @@ _ponysay()
|
|||
options='-v -h -l -f -W -q'
|
||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||
|
||||
if [ $prev = "-f" ]; then
|
||||
COMPREPLY=()
|
||||
|
||||
sysponies=/usr/share/ponysay/ponies/
|
||||
usrponies=~/.local/share/ponysay/ponies/
|
||||
if [[ $TERM = "linux" ]]; then
|
||||
sysponies=/usr/share/ponysay/ttyponies/
|
||||
usrponies=~/.local/share/ponysay/ttyponies/
|
||||
fi
|
||||
|
||||
[ -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" ) )
|
||||
if [ $prev = "-f" ]; then
|
||||
ponies=$('/usr/bin/ponysay.py' --onelist)
|
||||
COMPREPLY=( $( compgen -W "$ponies" -- "$cur" ) )
|
||||
|
||||
elif [ $prev = "-q" ]; then
|
||||
quoters=$('/usr/bin/ponysay.py' --quoters)
|
||||
COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) )
|
||||
|
||||
elif [ $prev = "-W" ]; then
|
||||
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
||||
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
|
||||
|
||||
elif [ $prev = "-q" ]; then
|
||||
qcmd=/usr/lib/ponysay/pq4ps
|
||||
quoters=$($qcmd -l)
|
||||
COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) )
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue