diff options
Diffstat (limited to 'completion')
-rw-r--r-- | completion/bash-completion.sh | 18 | ||||
-rw-r--r-- | completion/fish-completion.fish | 24 |
2 files changed, 37 insertions, 5 deletions
diff --git a/completion/bash-completion.sh b/completion/bash-completion.sh index 82eb608..53c53ef 100644 --- a/completion/bash-completion.sh +++ b/completion/bash-completion.sh @@ -5,16 +5,22 @@ _ponysay() local cur prev words cword _init_completion -n = || return - COMPREPLY=( $( compgen -W '-v -h -l -f -W' -- "$cur" ) ) + quotes=$(pq4ps --list 2>/dev/null) + quotesexit=$? + options='-v -h -l -f -W' + if [[ $quotesexit = 0 ]]; then + options="$options -q" + fi + COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) if [[ $prev = "-f" ]]; then COMPREPLY=() sysponies=/usr/share/ponysay/ponies/ - usrponies=~/.ponies/ + usrponies=~/.local/share/ponysay/ponies/ if [[ $TERM = "linux" ]]; then sysponies=/usr/share/ponysay/ttyponies/ - usrponies=~/.ttyponies/ + usrponies=~/.local/share/ponysay/ttyponies/ fi if [[ -d $sysponies ]]; then @@ -24,8 +30,10 @@ _ponysay() COMPREPLY+=( $( compgen -W "$(ls --color=no $usrponies | sed -e 's/.pony//g')" -- "$cur" ) ) fi elif [[ $prev = "-W" ]]; then - cols=$( echo `tput cols` - 10 | bc ) - COMPREPLY=( $cols $( echo $cols / 2 | bc ) 100 60 ) + cols=$(( `stty size | cut -d ' ' -f 2` - 10 )) + COMPREPLY=( $cols $(( $cols / 2 )) 100 60 ) + elif [[ $quotesexit = 0 ]] && [[ $prev = "-q" ]]; then + COMPREPLY=( $( compgen -W "$quotes" -- "$cur" ) ) fi } diff --git a/completion/fish-completion.fish b/completion/fish-completion.fish new file mode 100644 index 0000000..ea98382 --- /dev/null +++ b/completion/fish-completion.fish @@ -0,0 +1,24 @@ + +# Completions for ponysay & ponythink +# https://github.com/erkin/ponysay/ +# +# Author: Elis Axelsson <etu AT elis DOT nu> + + +if test -d /usr/share/ponysay/ponies/ + set -g systemponies (ls --color=no /usr/share/ponysay/ponies/ | sed 's/\.pony/\t Pony from \/usr\/share\/ponysay\/ponies\//') +end + +if test -d ~/.local/share/ponysay/ponies/ + set -g homeponies (ls --color=no ~/.local/share/ponysay/ponies/ | sed 's/\.pony/\t Pony from ~\/.local\/share\/ponysay\/ponies\//') +end + +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 f -a "$systemponies $homeponies" --description "Select a pony, either a filename or pony name" +complete -c ponysay -s W -a "Integer" --description "The screen column where the message should be wrapped" + +set -e systemponies +set -e homeponies + |