From dce179f8a3ac7f6a349deda010c9f811b78c17ce Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 18 Aug 2012 16:37:55 +0200 Subject: simplier completion --- completion/bash-completion.sh | 24 +++++++----------------- completion/fish-completion.fish | 31 ++++--------------------------- 2 files changed, 11 insertions(+), 44 deletions(-) (limited to 'completion') diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh index 26e1134..11b99ea 100644 --- a/completion/bash-completion.sh +++ b/completion/bash-completion.sh @@ -8,28 +8,18 @@ _ponysay() options='-v -h -l -f -W -q' COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - if [ $prev = "-f" ]; then - COMPREPLY=() - - sysponies=/usr/share/ponysay/ponies/ - usrponies=~/.local/share/ponysay/ponies/ - if [[ $TERM = "linux" ]]; then - sysponies=/usr/share/ponysay/ttyponies/ - usrponies=~/.local/share/ponysay/ttyponies/ - fi - - [ -d $sysponies ] && 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" ) ) + if [ $prev = "-f" ]; then + ponies=$('/usr/bin/ponysay.py' --onelist) + COMPREPLY=( $( compgen -W "$ponies" -- "$cur" ) ) + + elif [ $prev = "-q" ]; then + quoters=$('/usr/bin/ponysay.py' --quoters) + COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) ) elif [ $prev = "-W" ]; then cols=$(( `stty size | cut -d ' ' -f 2` - 10 )) COMPREPLY=( $cols $(( $cols / 2 )) 100 60 ) - elif [ $prev = "-q" ]; then - qcmd=/usr/lib/ponysay/pq4ps - quoters=$($qcmd -l) - COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) ) - fi } diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish index 89f7a19..727460b 100644 --- a/completion/fish-completion.fish +++ b/completion/fish-completion.fish @@ -3,43 +3,20 @@ # # Author: Elis Axelsson -if test $TERM = "linux" - set -g systempath /usr/share/ponysay/ttyponies/ - set -g homepath ~/.local/share/ponysay/ttyponies/ -else - set -g systempath /usr/share/ponysay/ponies/ - set -g homepath ~/.local/share/ponysay/ponies/ -end - -if test -d $systempath - set -g systemponies (ls --color=no $systempath | sed -e 's/\.pony//' -e 's/_.*//' | perl -pe 's/([a-z])([A-Z])/\1\\\ \2/' ) -end - -if test -d $homepath - set -g homeponies (ls --color=no $homepath | sed -e 's/\.pony//' -e 's/_.*//' | perl -pe 's/([a-z])([A-Z])/\1\\\ \2/' ) -end - - -set -g qcmd /usr/lib/ponysay/pq4ps -set -g quoters ($qcmd -l) +set -g ponies ('/usr/bin/ponysay.pl' --onelist) +set -g quoters ('/usr/bin/ponysay.pl' --quoters) complete -c ponysay -s h --description "Help 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 with alternatives" -complete -c ponysay -s f -a "$homeponies $systemponies" --description "Select a pony" +complete -c ponysay -s f -a "$ponies" --description "Select a pony" 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" -set -e systempath -set -e homepath - -set -e systemponies -set -e homeponies - -set -e qcmd +set -e ponies set -e quoters -- cgit From afcc9dc82981e6b334e5b4d8e79e19925ca9600e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 19 Aug 2012 03:30:11 +0200 Subject: info update + bash completion improvement (long options are suggested) --- completion/bash-completion.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'completion') diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh index 11b99ea..ca6755e 100644 --- a/completion/bash-completion.sh +++ b/completion/bash-completion.sh @@ -8,15 +8,15 @@ _ponysay() options='-v -h -l -f -W -q' COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) - if [ $prev = "-f" ]; then + if [ $prev = "-f" ] || [ $prev = "--pony" ]; then ponies=$('/usr/bin/ponysay.py' --onelist) COMPREPLY=( $( compgen -W "$ponies" -- "$cur" ) ) - elif [ $prev = "-q" ]; then + elif [ $prev = "-q" ] || [ $prev = "--quote" ]; then quoters=$('/usr/bin/ponysay.py' --quoters) COMPREPLY=( $( compgen -W "$quoters" -- "$cur" ) ) - elif [ $prev = "-W" ]; then + elif [ $prev = "-W" ] || [ $prev = "--wrap" ]; then cols=$(( `stty size | cut -d ' ' -f 2` - 10 )) COMPREPLY=( $cols $(( $cols / 2 )) 100 60 ) -- cgit From 1ca00b100a480c5347875c1607b80954d1d400fc Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sun, 19 Aug 2012 10:05:29 +0200 Subject: Updated fish-completions --- completion/fish-completion.fish | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'completion') diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish index 727460b..15bd132 100644 --- a/completion/fish-completion.fish +++ b/completion/fish-completion.fish @@ -1,20 +1,19 @@ -# Completions for ponysay +# FISH completions for ponysay # https://github.com/erkin/ponysay/ # # Author: Elis Axelsson +set -g ponies ('/usr/bin/ponysay.py' --onelist) +set -g quoters ('/usr/bin/ponysay.py' --quoters) -set -g ponies ('/usr/bin/ponysay.pl' --onelist) -set -g quoters ('/usr/bin/ponysay.pl' --quoters) - -complete -c ponysay -s h --description "Help 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 with alternatives" -complete -c ponysay -s f -a "$ponies" --description "Select a pony" -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 h -l help --description "help of ponysay" +complete -c ponysay -s v -l version --description "version of ponysay" +complete -c ponysay -s l -l list --description "list pony files" +complete -c ponysay -s L -l altlist --description "list pony files with alternatives" +complete -c ponysay -s f -l pony -a "$ponies" --description "select a pony" +complete -c ponysay -s q -l quote -a "$quoters" --description "select a pony which will quote herself" +complete -c ponysay -s W -l wrap -a "Integer" --description "specify the column when the message should be wrapped" set -e ponies -- cgit From e3176be013f6aa5b4d9a151f824e8a2067a4cf4b Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sun, 19 Aug 2012 10:54:33 +0200 Subject: Updated fish-completions again, removed some quotes, changed to long-options to make it more clear, added option for the message --- completion/fish-completion.fish | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'completion') diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish index 15bd132..6cd8b99 100644 --- a/completion/fish-completion.fish +++ b/completion/fish-completion.fish @@ -3,18 +3,18 @@ # # Author: Elis Axelsson -set -g ponies ('/usr/bin/ponysay.py' --onelist) -set -g quoters ('/usr/bin/ponysay.py' --quoters) +set -g ponies (/usr/bin/ponysay.py --onelist) +set -g quoters (/usr/bin/ponysay.py --quoters) -complete -c ponysay -s h -l help --description "help of ponysay" -complete -c ponysay -s v -l version --description "version of ponysay" -complete -c ponysay -s l -l list --description "list pony files" -complete -c ponysay -s L -l altlist --description "list pony files with alternatives" -complete -c ponysay -s f -l pony -a "$ponies" --description "select a pony" -complete -c ponysay -s q -l quote -a "$quoters" --description "select a pony which will quote herself" -complete -c ponysay -s W -l wrap -a "Integer" --description "specify the column when the message should be wrapped" - +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 files' +complete --command ponysay --short-option L --long-option altlist --description 'list pony files with alternatives' +complete --command ponysay --short-option f --long-option pony --arguments "$ponies" --description 'pony' +complete --command ponysay --short-option q --long-option quote --arguments "$quoters" --no-files --description 'pony' +complete --command ponysay --short-option W --long-option wrap --arguments 'Integer' --description 'specify the column when the message should be wrapped' +complete --command ponysay --arguments 'MESSAGE' set -e ponies set -e quoters -- cgit