diff options
author | jaseg <s@jaseg.de> | 2013-04-01 19:19:55 +0200 |
---|---|---|
committer | jaseg <s@jaseg.de> | 2013-04-01 19:21:27 +0200 |
commit | 7e85ffea332ee0b45a632dde0f8a3d8d90ca4549 (patch) | |
tree | 7d9ab54061c9859791142ed6dc8d8b50b0e99bf1 | |
parent | 59eca1fc5d17b85e3e4afaa2af0490d08cc50d98 (diff) | |
download | ponysay-7e85ffea332ee0b45a632dde0f8a3d8d90ca4549.tar.gz ponysay-7e85ffea332ee0b45a632dde0f8a3d8d90ca4549.tar.bz2 ponysay-7e85ffea332ee0b45a632dde0f8a3d8d90ca4549.zip |
Added zsh and bash completion
-rw-r--r-- | Makefile | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | completion/bash-completion.sh | 45 | ||||
-rw-r--r-- | completion/fish-completion.fish | 27 | ||||
-rw-r--r-- | completion/zsh-completion.sh | 29 | ||||
-rw-r--r-- | completion/zsh-completion.zsh | 33 |
5 files changed, 51 insertions, 91 deletions
@@ -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 diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh index ae6a744..6a346f5 100644..100755 --- a/completion/bash-completion.sh +++ b/completion/bash-completion.sh @@ -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 diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish deleted file mode 100644 index 24e9b05..0000000 --- a/completion/fish-completion.fish +++ /dev/null @@ -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 diff --git a/completion/zsh-completion.sh b/completion/zsh-completion.sh new file mode 100644 index 0000000..4e280ba --- /dev/null +++ b/completion/zsh-completion.sh @@ -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" + diff --git a/completion/zsh-completion.zsh b/completion/zsh-completion.zsh deleted file mode 100644 index ec00594..0000000 --- a/completion/zsh-completion.zsh +++ /dev/null @@ -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 |