mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-26 06:07:59 +01:00
bash and fish completion knowns which ponies have quotes
This commit is contained in:
parent
532ab6c6ee
commit
e868a23400
2 changed files with 20 additions and 11 deletions
|
@ -8,7 +8,7 @@ _ponysay()
|
||||||
options='-v -h -l -f -W -q'
|
options='-v -h -l -f -W -q'
|
||||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||||
|
|
||||||
if [[ $prev = "-f" ]]; then
|
if [ $prev = "-f" ]; then
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
|
||||||
sysponies=/usr/share/ponysay/ponies/
|
sysponies=/usr/share/ponysay/ponies/
|
||||||
|
@ -18,17 +18,18 @@ _ponysay()
|
||||||
usrponies=~/.local/share/ponysay/ttyponies/
|
usrponies=~/.local/share/ponysay/ttyponies/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d $sysponies ]]; then
|
[ -d $sysponies ] && COMPREPLY+=( $( compgen -W "$(ls --color=no $sysponies | sed -e 's/.pony//g')" -- "$cur" ) )
|
||||||
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" ) )
|
||||||
fi
|
|
||||||
if [[ -d $usrponies ]]; then
|
elif [ $prev = "-W" ]; then
|
||||||
COMPREPLY+=( $( compgen -W "$(ls --color=no $usrponies | sed -e 's/.pony//g')" -- "$cur" ) )
|
|
||||||
fi
|
|
||||||
elif [[ $prev = "-W" ]]; then
|
|
||||||
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
||||||
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
|
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 )
|
||||||
elif [[ $prev = "-q" ]]; then
|
|
||||||
COMPREPLY=( $( compgen -W "$quotes" -- "$cur" ) )
|
elif [ $prev = "-q" ]; then
|
||||||
|
qcmd=/usr/lib/ponysay/pq4ps
|
||||||
|
quoters=$($qcmd -l)
|
||||||
|
COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) )
|
||||||
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,25 @@ if test -d $homepath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
set -g qcmd /usr/lib/ponysay/pq4ps
|
||||||
|
set -g quoters ($qcmd -l)
|
||||||
|
|
||||||
|
|
||||||
complete -c ponysay -s h --description "Help of ponysay"
|
complete -c ponysay -s h --description "Help of ponysay"
|
||||||
complete -c ponysay -s v --description "Version of ponysay"
|
complete -c ponysay -s v --description "Version of ponysay"
|
||||||
complete -c ponysay -s l --description "List pony files"
|
complete -c ponysay -s l --description "List pony files"
|
||||||
complete -c ponysay -s L --description "List pony files with alternatives"
|
complete -c ponysay -s L --description "List pony files with alternatives"
|
||||||
complete -c ponysay -s f -a "$homeponies $systemponies" --description "Select a pony"
|
complete -c ponysay -s f -a "$homeponies $systemponies" --description "Select a pony"
|
||||||
complete -c ponysay -s q -a "$homeponies $systemponies" --description "Select ponies for MLP:FiM quotes"
|
complete -c ponysay -s q -a "$quoters" --description "Select ponies for MLP:FiM quotes"
|
||||||
complete -c ponysay -s W -a "Integer" --description "The screen column where the message should be wrapped"
|
complete -c ponysay -s W -a "Integer" --description "The screen column where the message should be wrapped"
|
||||||
|
|
||||||
|
|
||||||
set -e systempath
|
set -e systempath
|
||||||
set -e homepath
|
set -e homepath
|
||||||
|
|
||||||
set -e systemponies
|
set -e systemponies
|
||||||
set -e homeponies
|
set -e homeponies
|
||||||
|
|
||||||
|
set -e qcmd
|
||||||
|
set -e quoters
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue