mirror of
https://github.com/erkin/ponysay.git
synced 2024-11-26 06:07:59 +01:00
shell completion improvements
This commit is contained in:
parent
23d84d1b55
commit
8f2cb1bb30
3 changed files with 7 additions and 8 deletions
|
@ -5,12 +5,7 @@ _ponysay()
|
||||||
local cur prev words cword
|
local cur prev words cword
|
||||||
_init_completion -n = || return
|
_init_completion -n = || return
|
||||||
|
|
||||||
quotes=$(/usr/lib/ponysay/pq4ps --list 2>/dev/null)
|
options='-v -h -l -f -W -q'
|
||||||
quotesexit=$?
|
|
||||||
options='-v -h -l -f -W'
|
|
||||||
if [[ $quotesexit = 0 ]]; then
|
|
||||||
options="$options -q"
|
|
||||||
fi
|
|
||||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||||
|
|
||||||
if [[ $prev = "-f" ]]; then
|
if [[ $prev = "-f" ]]; then
|
||||||
|
@ -32,7 +27,7 @@ _ponysay()
|
||||||
elif [[ $prev = "-W" ]]; then
|
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 [[ $quotesexit = 0 ]] && [[ $prev = "-q" ]]; then
|
elif [[ $prev = "-q" ]]; then
|
||||||
COMPREPLY=( $( compgen -W "$quotes" -- "$cur" ) )
|
COMPREPLY=( $( compgen -W "$quotes" -- "$cur" ) )
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ end
|
||||||
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 f -a "$homeponies $systemponies" --description "Ponyfile"
|
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 q -a "$homeponies $systemponies" --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"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,9 @@ _shortopts=(
|
||||||
'-v[Show version and exit]'
|
'-v[Show version and exit]'
|
||||||
'-h[Show this help and exit]'
|
'-h[Show this help and exit]'
|
||||||
'-l[list ponyfiles]'
|
'-l[list ponyfiles]'
|
||||||
|
'-L[list ponyfiles with alternatives]'
|
||||||
'-f[Select a pony (either a filename or a ponyname]: :_path_files -W "/usr/share/ponysay/ponies" -g "*(\:r)"'
|
'-f[Select a pony (either a filename or a ponyname]: :_path_files -W "/usr/share/ponysay/ponies" -g "*(\:r)"'
|
||||||
|
'-q[Select ponies for MLP:FiM quotes]'
|
||||||
'-W[The screen column where the message should be wrapped]'
|
'-W[The screen column where the message should be wrapped]'
|
||||||
)
|
)
|
||||||
_arguments -s : \
|
_arguments -s : \
|
||||||
|
|
Loading…
Reference in a new issue