Added zsh and bash completion
This commit is contained in:
parent
59eca1fc5d
commit
7e85ffea33
5 changed files with 51 additions and 91 deletions
8
Makefile
8
Makefile
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
PREFIX?=/usr
|
||||
PREFIX?=/usr/local
|
||||
|
||||
install:
|
||||
install -m 0755 ponysay.py $(PREFIX)/bin
|
||||
|
|
@ -10,6 +10,8 @@ install:
|
|||
install -m 0755 -d $(PREFIX)/share/doc/ponysay
|
||||
install -m 0755 -t $(PREFIX)/share/doc/ponysay COPYING
|
||||
install -m 0755 -t $(PREFIX)/share/doc/ponysay README.md
|
||||
install -m 0644 completion/zsh-completion.sh /usr/share/zsh/site-functions/_ponysay
|
||||
install -m 0755 completion/bash-completion.sh /etc/bash_completion.d/ponysay.sh
|
||||
|
||||
uninstall:
|
||||
rm $(PREFIX)/bin/ponysay
|
||||
|
|
@ -19,4 +21,8 @@ uninstall:
|
|||
rmdir $(PREFIX)/share/ponysay
|
||||
rm $(PREFIX)/share/doc/ponysay/*
|
||||
rmdir $(PREFIX)/share/doc/ponysay
|
||||
rm /usr/share/zsh/site-functions/_ponysay
|
||||
rm /etc/bash_completion.d/ponysay.sh
|
||||
|
||||
reinstall: uninstall install
|
||||
|
||||
|
|
|
|||
45
completion/bash-completion.sh
Normal file → Executable file
45
completion/bash-completion.sh
Normal file → Executable file
|
|
@ -1,36 +1,21 @@
|
|||
# bash completion for ponysay -*- shell-script -*-
|
||||
#!bash
|
||||
#
|
||||
# this is bash completion function file for ponysay.py.
|
||||
# generated by genzshcomp(ver: 0.5.1)
|
||||
#
|
||||
|
||||
_ponysay()
|
||||
_ponysay.py()
|
||||
{
|
||||
local cur prev words cword
|
||||
_init_completion -n = || return
|
||||
|
||||
options="--version --help --list --altlist --pony --wrap --quote --balloonlist --balloon --file ++file ++pony ++list ++altlist --all ++all"
|
||||
options="$options --256-colours --tty-colours --kms-colours"
|
||||
COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
|
||||
|
||||
if [ $prev = "-f" ] || [ $prev = "--pony" ] || [ $prev = "--file" ]; then
|
||||
ponies=$('/usr/bin/ponysay' --onelist)
|
||||
COMPREPLY=( $( compgen -W "$ponies" -- "$cur" ) )
|
||||
local cur
|
||||
local cmd
|
||||
|
||||
elif [ $prev = "-F" ] || [ $prev = "++pony" ] || [ $prev = "++file" ]; then
|
||||
extraponies=$('/usr/bin/ponysay' ++onelist)
|
||||
COMPREPLY=( $( compgen -W "$extraponies" -- "$cur" ) )
|
||||
cur=${COMP_WORDS[$COMP_CWORD]}
|
||||
cmd=( ${COMP_WORDS[@]} )
|
||||
|
||||
elif [ $prev = "-q" ] || [ $prev = "--quote" ]; then
|
||||
quoters=$('/usr/bin/ponysay' --quoters)
|
||||
COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) )
|
||||
|
||||
elif [ $prev = "-b" ] || [ $prev = "--balloon" ] || [ $prev = "--bubble" ]; then
|
||||
balloons=$('/usr/bin/ponysay' --balloonlist)
|
||||
COMPREPLY=( $( compgen -W "$balloons" -- "$cur" ) )
|
||||
|
||||
elif [ $prev = "-W" ] || [ $prev = "--wrap" ]; then
|
||||
cols=$(( `stty size | cut -d ' ' -f 2` - 10 ))
|
||||
COMPREPLY=( $cols $(( $cols / 2 )) 100 60 none inherit )
|
||||
|
||||
fi
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $( compgen -W "-h --help --pony -p --quote -q --center -c --center-text -C --width -w --balloon -b" -- $cur ) )
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F _ponysay ponysay
|
||||
|
||||
complete -F _ponysay.py -o default ponysay.py
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
# fish completion for ponysay -*- shell-script -*-
|
||||
# Author: Elis Axelsson <etu AT elis DOT nu>
|
||||
|
||||
set -g ponies ('/usr/bin/ponysay' --onelist)
|
||||
set -g xponies ('/usr/bin/ponysay' ++onelist)
|
||||
set -g quoters ('/usr/bin/ponysay' --quoters)
|
||||
set -g balloons ('/usr/bin/ponysay' --balloonlist)
|
||||
|
||||
|
||||
## TODO: update with options [see info manual]: +l +L ++list ++altlist ++file --file ++pony {-A, +A, -V, -K, -X}(with alternative)
|
||||
complete --command ponysay --short-option h --long-option help --description 'help of ponysay'
|
||||
complete --command ponysay --short-option v --long-option version --description 'version of ponysay'
|
||||
complete --command ponysay --short-option l --long-option list --description 'list pony names'
|
||||
complete --command ponysay --short-option L --long-option altlist --description 'list pony names with alternatives'
|
||||
complete --command ponysay --short-option B --long-option balloonlist --description 'list balloon style names'
|
||||
complete --command ponysay --short-option f --long-option pony --arguments "$ponies" --description 'pony'
|
||||
complete --command ponysay --short-option F --arguments "$xponies" --description 'extra pony'
|
||||
complete --command ponysay --short-option q --long-option quote --arguments "$quoters" --no-files --description 'pony'
|
||||
complete --command ponysay --short-option b --long-option balloon --arguments "$balloons" --no-files --description 'balloon style'
|
||||
complete --command ponysay --short-option W --long-option wrap --arguments 'Integer' --description 'specify the column when the message should be wrapped' ## TODO arguments `none` and `inherit` should be suggested
|
||||
complete --command ponysay --arguments 'MESSAGE'
|
||||
|
||||
|
||||
set -e ponies
|
||||
set -e xponies
|
||||
set -e quoters
|
||||
set -e balloons
|
||||
29
completion/zsh-completion.sh
Normal file
29
completion/zsh-completion.sh
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#compdef ponysay ponythink
|
||||
#
|
||||
# this is zsh completion function file.
|
||||
# generated by genzshcomp(ver: 0.5.1)
|
||||
#
|
||||
|
||||
typeset -A opt_args
|
||||
local context state line
|
||||
|
||||
local -a _available_ponies
|
||||
(( $+functions[_ponysay_pony] )) || _ponysay_pony()
|
||||
{
|
||||
(( $#_available_ponies )) || _available_ponies=($(ponysay -p list) )
|
||||
compadd "$@" -a _available_ponies
|
||||
}
|
||||
|
||||
_ponysay_balloons(){
|
||||
[[ "$words" == ponythink* ]] && compadd "$@" cowsay ascii || compadd "$@" cowsay ascii unicode round linux-vt
|
||||
}
|
||||
|
||||
_arguments -s -w -S \
|
||||
"(-h --help)"{-h,--help}"[show this help message and exit]" \
|
||||
"(-p= --pony=)"{-p,--pony}"[The name of the pony to be used. Use \"-p list\" to list all ponies, \"-p random\" (default) to use a random pony.]:PONY:_ponysay_pony" \
|
||||
"(-q --quote)"{-q,--quote}"[Use a random quote of the pony being displayed as text]" \
|
||||
"(-c --center)"{-c,--center}"[Center the pony]" \
|
||||
"(-C --center-text)"{-C,--center-text}"[Center the text in the bubble]" \
|
||||
"(-w= --width=)"{-w,--width}"[Terminal width. Use 0 for unlimited width. Default: autodetect]:WIDTH: " \
|
||||
"(-b= --balloon=)"{-b,--balloon}"[Balloon style to use. Use \"-b list\" to list available styles.]:BALLOON:_ponysay_balloons"
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
# zsh completion for ponysay -*- shell-script -*-
|
||||
#compdef ponysay ponythink
|
||||
_opts=(
|
||||
'(--version -v)'{-v,--version}'[Show version and exit]'
|
||||
'(-h --help)'{-h,--help}'[Show this help and exit]'
|
||||
'(-l --list)'{-l,--list}'[list pony names]'
|
||||
'(-L --altlist)'{-L,--altlist}'[list pony names with alternatives]'
|
||||
'(+l ++list)'{+l,++list}'[list extra pony names]'
|
||||
'(+L ++altlist)'{+L,++altlist}'[list extra pony names with alternatives]'
|
||||
'(-B --balloonlist)'{-B,--balloonlist}'[list balloon style names]'
|
||||
'(-b --ballon)'{-b,--balloon}'[Selecy a balloon style]: :_path_files -W '/usr/share/ponysay/balloons' -g "*(\:r)"'
|
||||
'(-c --compact)'{-c,--compat}'[Compress messages.]'
|
||||
'(-W --wrap)'{-W,--wrap}'[The screen column where the message should be wrapped]' # TODO arguments `none` and `inherit` should be suggested
|
||||
)
|
||||
_tty_select=(
|
||||
'(-q --quite)'{-q,--quote}'[Select ponies for MLP:FiM quotes]: :_path_files -W '/usr/share/ponysay/ttyponies' -g "*(\:r)"'
|
||||
'(-f --pony)'{-f,--pony}'[select pony]: :_path_files -W '/usr/share/ponysay/ttyponies/' -g "*(\:r)"'
|
||||
'(-F ++pony)'{-F,++pony}'[Select a extra pony]: :_path_files -W '/usr/share/ponysay/extrattyponies' -g "*(\:r)"'
|
||||
)
|
||||
_select=(
|
||||
'(-q --quite)'{-q,--quote}'[Select ponies for MLP:FiM quotes]: :_path_files -W '/usr/share/ponysay/ponies' -g "*(\:r)"'
|
||||
'(-f --pony)'{-f,--pony}'[select pony]: :_path_files -W '/usr/share/ponysay/ponies/' -g "*(\:r)"'
|
||||
'(-F ++pony)'{-F,++pony}'[Select a extra pony]: :_path_files -W '/usr/share/ponysay/extraponies' -g "*(\:r)"'
|
||||
)
|
||||
if [[ "${(f)"$(tty)"##*/}" == "tty*" ]]; then
|
||||
_arguments \
|
||||
"$_opts[@]" \
|
||||
"$_tty_select[@]"
|
||||
else
|
||||
_arguments \
|
||||
"$_opts[@]" \
|
||||
"$_select[@]"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue