diff options
Diffstat (limited to 'ponysay')
-rwxr-xr-x | ponysay | 53 |
1 files changed, 45 insertions, 8 deletions
@@ -12,8 +12,21 @@ if [ "$TERM" = "linux" ]; then HOMEPONIES="${HOME}/.local/share/ponysay/ttyponies" fi -cmd=cowsay -[[ ${0} == *ponythink ]] && cmd=cowthink +if [[ "$PONYSAY_COWSAY" = "" ]]; then + cmd=cowsay + customcmd=0 +else + cmd="$PONYSAY_COWSAY" + customcmd=1 +fi +[[ ${0} == *ponythink ]] && + if [[ "$PONYSAY_COWTHINK" = "" ]]; then + cmd=cowthink + customcmd=0 + else + cmd="$PONYSAY_COWTHINK" + customcmd=1 + fi version() { echo "ponysay v$version" @@ -67,7 +80,7 @@ _linklist() { scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` - perl '/dev/stdin' $(echo $args) <<EOF | sed -e 's/ /_/g' > /dev/shm/ponysay~ + perl '/dev/stdin' $(echo $args) <<EOF | sed -e 's/ /_/g' > '/dev/shm/.ponysay~' #!/usr/bin/perl #Author: Mattias Andrée (maandree@kth.se) @@ -134,7 +147,8 @@ while (\$i < \$argc) } EOF - perl $listcmd $scrw $(cat /dev/shm/ponysay~) | sed -e 's/_/ /g' | qlist + perl $listcmd $scrw $(cat "/dev/shm/.ponysay~") | sed -e 's/_/ /g' | qlist + rm '/dev/shm/.ponysay~' } linklist() { @@ -188,7 +202,7 @@ say() { function wtrunc { - if [ "$PONYSAY_FULL_WIDTH" = 'no' ] || [ "$PONYSAY_FULL_WIDTH" = 'n' ] || [ "$PONYSAY_FULL_WIDTH" = '0' ]; then + if [ "$PONYSAY_FULL_WIDTH" = 'yes' ] || [ "$PONYSAY_FULL_WIDTH" = 'y' ] || [ "$PONYSAY_FULL_WIDTH" = '1' ]; then cat else WIDTH=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` @@ -208,14 +222,37 @@ say() { tail --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES )) } + if [[ $customcmd = 0 ]]; then + function cowcmd + { + echo "standrd $cmd" + pcmd='#!/usr/bin/perl\nuse utf8;' + ccmd=$(for c in $(echo $PATH":" | sed -e 's/:/\/'"$cmd"' /g'); do if [[ -f $c ]]; then echo $c; break; fi done) + echo "is $cmd" + if [[ ${0} == *ponythink ]]; then + cat <(echo -e $pcmd) $ccmd > "/dev/shm/.ponythink" + perl '/dev/shm/.ponythink' "$@" + rm '/dev/shm/.ponythink' + else + perl <(cat <(echo -e $pcmd) $ccmd) "$@" + fi + } + else + function cowcmd + { + echo "custom $cmd" + $cmd "$@" + } + fi + if [ "$TERM" = "linux" ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'yes' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'y' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = '1' ]; then if [ "$PONYSAY_BOTTOM" = 'yes' ] || [ "$PONYSAY_BOTTOM" = 'y' ] || [ "$PONYSAY_BOTTOM" = '1' ]; then - exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunctail + cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunctail else - exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunchead + cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunchead fi else - exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc + cowcmd -f "$pony" "${wrap:+-W$wrap}" | wtrunc fi } |