From 7e85ffea332ee0b45a632dde0f8a3d8d90ca4549 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 1 Apr 2013 19:19:55 +0200 Subject: Added zsh and bash completion --- completion/bash-completion.sh | 45 ++++++++++++++--------------------------- completion/fish-completion.fish | 27 ------------------------- completion/zsh-completion.sh | 29 ++++++++++++++++++++++++++ completion/zsh-completion.zsh | 33 ------------------------------ 4 files changed, 44 insertions(+), 90 deletions(-) mode change 100644 => 100755 completion/bash-completion.sh delete mode 100644 completion/fish-completion.fish create mode 100644 completion/zsh-completion.sh delete mode 100644 completion/zsh-completion.zsh (limited to 'completion') diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh old mode 100644 new mode 100755 index ae6a744..6a346f5 --- 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 - -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 -- cgit