From 96480e57a0e0a793a31a1a65df0452e95cf092d7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 12 May 2012 21:35:14 +0300 Subject: You forgot to increase version number here. --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index e07e1e3..88e5941 100755 --- a/ponysay +++ b/ponysay @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version=0.8 +version=0.9 SYSTEMPONIES=/usr/share/ponies HOMEPONIES="${HOME}/.ponies" pony="*" -- cgit From 85c54340c364a641c6846e15ff052f1928e3c0af Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 21 May 2012 22:55:31 +0300 Subject: Fixed typo in comment. --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 88e5941..6f1cf4e 100755 --- a/ponysay +++ b/ponysay @@ -45,7 +45,7 @@ Options: EOF } -# if no stdin and no argumrnts then print usage and exit +# if no stdin and no arguments then print usage and exit if [[ -t 0 && $# == 0 ]]; then usage exit -- cgit From 63e848a93f69e2028532cf89aa44eded21737cd5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 3 Jul 2012 09:57:53 +0200 Subject: Ponies are truncated on height under TTY, leaving 2 lines for shell interaction. export PONYSAY_BOTTOM=1 to show bottom instread of top. --- ponysay | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 6f1cf4e..a04d8d7 100755 --- a/ponysay +++ b/ponysay @@ -59,10 +59,28 @@ say() { echo -ne '\ec' fi - exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | (ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || - cat) + function wtrunc + { + ponysaytruncater `tput cols || echo 0` 2>/dev/null || + ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || + ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || + cat + } + + function htrunc + { + head --lines=$(( $(stty size <&2 | cut -d ' ' -f 1) - 2 )) + } + + if [ "$TERM" = "linux" ]; then + if [ "$PONYSAY_BOTTOM" = 'yes' ] || [ "$PONYSAY_BOTTOM" = 'y' ] || [ "$PONYSAY_BOTTOM" = '1' ]; then + exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | tac | htrunc | tac + else + exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunc + fi + else + exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc + fi } while getopts f:W:lhv OPT -- cgit From 46c3e0d74e25de74cfbb84fb2d6f04e7f6e318a9 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 4 Jul 2012 10:32:12 +0200 Subject: improving manpage + minor change in ponysay --help + sorting credits file --- ponysay | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index a04d8d7..4b5e912 100755 --- a/ponysay +++ b/ponysay @@ -34,14 +34,16 @@ usage() { Usage: ${0##*/} [options] [message] -If [message] is not provided, reads the message from STDIN +If [message] is not provided, reads the message from STDIN. Options: - -v Show version and exit - -h Show this help and exit - -l List ponyfiles. - -f[name] Select a pony (Either a filename or a pony name) - -W[column] The screen column where the message should be wrapped + -v Show version and exit. + -h Show this help and exit. + -l List pony files. + -f[name] Select a pony (either a file name or a pony name.) + -W[column] The screen column where the message should be wrapped. + +See man ponysay(1) for more information. EOF } -- cgit From 4063e82a1512515358480b53d87223f71e0efc20 Mon Sep 17 00:00:00 2001 From: Pablo Lezaeta Date: Wed, 4 Jul 2012 23:30:29 -0400 Subject: Migration to /usr/share/ponysay/{,tty}ponies (need more reviews) --- ponysay | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index a04d8d7..b3c31b8 100755 --- a/ponysay +++ b/ponysay @@ -1,13 +1,13 @@ #!/usr/bin/env bash version=0.9 -SYSTEMPONIES=/usr/share/ponies +SYSTEMPONIES=/usr/share/ponysay/ponies HOMEPONIES="${HOME}/.ponies" pony="*" wrap= if [ "$TERM" = "linux" ]; then - SYSTEMPONIES=/usr/share/ttyponies + SYSTEMPONIES=/usr/share/ponysay/ttyponies HOMEPONIES="${HOME}/.ttyponies" fi -- cgit From 63849f33259e162396da696e0a66976d705b81a6 Mon Sep 17 00:00:00 2001 From: Pablo Lezaeta Date: Thu, 5 Jul 2012 00:27:35 -0400 Subject: Forget the /home/fyrefly right place ./.ponysay/{,tty}ponies --- ponysay | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 62d1ac8..2f60ab3 100755 --- a/ponysay +++ b/ponysay @@ -2,13 +2,13 @@ version=0.9 SYSTEMPONIES=/usr/share/ponysay/ponies -HOMEPONIES="${HOME}/.ponies" +HOMEPONIES="${HOME}/.ponysay/ponies" pony="*" wrap= if [ "$TERM" = "linux" ]; then SYSTEMPONIES=/usr/share/ponysay/ttyponies - HOMEPONIES="${HOME}/.ttyponies" + HOMEPONIES="${HOME}/.ponysay/ttyponies" fi cmd=cowsay -- cgit From 4a39ef423041bee3faafc99ee60bf0dbb1229868 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Jul 2012 09:14:14 +0200 Subject: ponythink in manpage + environment variables PONYSAY_SHELL_LINES and PONYSAY_FULL_WIDTH --- ponysay | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 4b5e912..9b5b2af 100755 --- a/ponysay +++ b/ponysay @@ -63,15 +63,22 @@ say() { function wtrunc { - ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || - cat + if [ "$PONYSAY_FULL_WIDTH" = 'no' ] || [ "$PONYSAY_FULL_WIDTH" = 'n' ] || [ "$PONYSAY_FULL_WIDTH" = '0' ]; then + cat + else + ponysaytruncater `tput cols || echo 0` 2>/dev/null || + ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || + ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || + cat + fi } function htrunc { - head --lines=$(( $(stty size <&2 | cut -d ' ' -f 1) - 2 )) + if [ "$PONYSAY_SHELL_LINES" = "" ]; then + PONYSAY_SHELL_LINES=2 + fi + head --lines=$(( $(stty size <&2 | cut -d ' ' -f 1) - $PONYSAY_SHELL_LINES )) } if [ "$TERM" = "linux" ]; then -- cgit From 348c0084a892b6967249e26a40f529301f7172e4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Jul 2012 09:17:43 +0200 Subject: environment variable PONYSAY_TRUNCATE_HEIGHT --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 9b5b2af..46c288e 100755 --- a/ponysay +++ b/ponysay @@ -81,7 +81,7 @@ say() { head --lines=$(( $(stty size <&2 | cut -d ' ' -f 1) - $PONYSAY_SHELL_LINES )) } - if [ "$TERM" = "linux" ]; then + 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 | tac | htrunc | tac else -- cgit From 2cc95ba021f4f295d974f51f5a4349aa370f3317 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Jul 2012 09:24:29 +0200 Subject: using stty and cut (coreutils) instead of tput (ncurses) for getting terminal width --- ponysay | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 46c288e..5958387 100755 --- a/ponysay +++ b/ponysay @@ -66,9 +66,10 @@ say() { if [ "$PONYSAY_FULL_WIDTH" = 'no' ] || [ "$PONYSAY_FULL_WIDTH" = 'n' ] || [ "$PONYSAY_FULL_WIDTH" = '0' ]; then cat else - ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ${HOME}/.local/bin/ponysaytruncater `tput cols || echo 0` 2>/dev/null || - ./ponysaytruncater `tput cols || echo 0` 2>/dev/null || + WIDTH=$((stty size <&2 || echo 0 0) | cut -d ' ' -f 2) + ponysaytruncater $WIDTH 2>/dev/null || + ${HOME}/.local/bin/ponysaytruncater $WIDTH 2>/dev/null || + ./ponysaytruncater $WIDTH 2>/dev/null || cat fi } -- cgit From 2f1566b74f83ea33d156cce3cee60f137db58489 Mon Sep 17 00:00:00 2001 From: Erkin Batu Altunbaş Date: Wed, 11 Jul 2012 18:36:18 +0300 Subject: I tried to make it a bit more portable. I hope I didn't screw something up. --- ponysay | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index e50b0b1..79e8339 100755 --- a/ponysay +++ b/ponysay @@ -1,13 +1,13 @@ #!/usr/bin/env bash -version=0.9 -SYSTEMPONIES=/usr/share/ponysay/ponies +version=0.10 +SYSTEMPONIES="/usr/share/ponysay/ponies" HOMEPONIES="${HOME}/.ponysay/ponies" pony="*" -wrap= +wrap="" if [ "$TERM" = "linux" ]; then - SYSTEMPONIES=/usr/share/ponysay/ttyponies + SYSTEMPONIES="/usr/share/ponysay/ttyponies" HOMEPONIES="${HOME}/.ponysay/ttyponies" fi @@ -66,7 +66,7 @@ say() { if [ "$PONYSAY_FULL_WIDTH" = 'no' ] || [ "$PONYSAY_FULL_WIDTH" = 'n' ] || [ "$PONYSAY_FULL_WIDTH" = '0' ]; then cat else - WIDTH=$((stty size <&2 || echo 0 0) | cut -d ' ' -f 2) + WIDTH=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` ponysaytruncater $WIDTH 2>/dev/null || ${HOME}/.local/bin/ponysaytruncater $WIDTH 2>/dev/null || ./ponysaytruncater $WIDTH 2>/dev/null || @@ -79,7 +79,7 @@ say() { if [ "$PONYSAY_SHELL_LINES" = "" ]; then PONYSAY_SHELL_LINES=2 fi - head --lines=$(( $(stty size <&2 | cut -d ' ' -f 1) - $PONYSAY_SHELL_LINES )) + head --lines=`( \`stty size <&2 | cut -d ' ' -f 1\` - $PONYSAY_SHELL_LINES )` } if [ "$TERM" = "linux" ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'yes' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'y' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = '1' ]; then @@ -106,7 +106,7 @@ do done shift $((OPTIND - 1)) -if ! hash $cmd &>/dev/null; then +hash $cmd &>/dev/null; if [ $? -ne 0 ]; then cat >&2 < Date: Wed, 11 Jul 2012 18:42:49 +0300 Subject: See comment on last edit. --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 79e8339..bfe74b7 100755 --- a/ponysay +++ b/ponysay @@ -79,7 +79,7 @@ say() { if [ "$PONYSAY_SHELL_LINES" = "" ]; then PONYSAY_SHELL_LINES=2 fi - head --lines=`( \`stty size <&2 | cut -d ' ' -f 1\` - $PONYSAY_SHELL_LINES )` + head --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES )) } if [ "$TERM" = "linux" ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'yes' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = 'y' ] || [ "$PONYSAY_TRUNCATE_HEIGHT" = '1' ]; then -- cgit From 0d7cbc70d75169e5debbe5c67b4eb8773835dd80 Mon Sep 17 00:00:00 2001 From: Erkin Batu Altunbaş Date: Fri, 13 Jul 2012 02:18:53 +0200 Subject: tiny fix in help --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index bfe74b7..7ec7943 100755 --- a/ponysay +++ b/ponysay @@ -43,7 +43,7 @@ Options: -f[name] Select a pony (either a file name or a pony name.) -W[column] The screen column where the message should be wrapped. -See man ponysay(1) for more information. +See man ponysay(6) for more information. EOF } -- cgit From 54dd31f5c67885fe9f29acc5766a502c183c6f67 Mon Sep 17 00:00:00 2001 From: Erkin Batu Altunbaş Date: Sun, 15 Jul 2012 17:49:47 +0200 Subject: First stable release. Let's see how stable it is... --- ponysay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 7ec7943..3e2908c 100755 --- a/ponysay +++ b/ponysay @@ -1,6 +1,6 @@ #!/usr/bin/env bash -version=0.10 +version=1.0 SYSTEMPONIES="/usr/share/ponysay/ponies" HOMEPONIES="${HOME}/.ponysay/ponies" pony="*" -- cgit From 8184d371a984d9a40c70d8a35d059daea5edab0a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 16 Jul 2012 11:49:50 +0200 Subject: ponysay -l is columnated, however a bit slow and limited to 80 in screen width --- ponysay | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index 3e2908c..dc36713 100755 --- a/ponysay +++ b/ponysay @@ -19,11 +19,29 @@ version() { } list() { - echo "ponyfiles located in $SYSTEMPONIES:" - ls -1 $SYSTEMPONIES | sed "s/.pony//" + scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2` + (( $scrw > 80 )) && scrw=80 + + echo -e "\\e[01mponyfiles located in $SYSTEMPONIES:\\e[21m" + files=`ls -1 $SYSTEMPONIES | sed "s/.pony//"` + maxw=1 + for file in $files; do + w=$(( `echo $file | wc -m` + 2 )) + (( $maxw < $w )) && maxw=$w + done + cols=$(( $scrw / $maxw )) + echo "$files" | pr -T --columns=$cols + if [[ -d $HOMEPONIES ]]; then - echo "ponyfiles located in $HOMEPONIES:" - ls -1 $HOMEPONIES | sed "s/.pony//" + echo -e "\\e[01mponyfiles located in $HOMEPONIES:\\e[21m" + files=`ls -1 $HOMEPONIES | sed "s/.pony//"` + maxw=1 + for file in $files; do + w=$(( `echo $file | wc -m` )) + (( $maxw < $w )) && maxw=$w + done + cols=$(( $scrw / $maxw )) + echo "$files" | pr -T --columns=$cols fi } -- cgit From 0ee48b90dec3c9c9a352d2060d7e477142fcc80c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 17 Jul 2012 00:14:49 +0200 Subject: using tail instread of tac | head | tac --- ponysay | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'ponysay') diff --git a/ponysay b/ponysay index dc36713..27ddfc5 100755 --- a/ponysay +++ b/ponysay @@ -92,19 +92,23 @@ say() { fi } - function htrunc + if [ "$PONYSAY_SHELL_LINES" = "" ]; then + PONYSAY_SHELL_LINES=2 + fi + function htrunchead { - if [ "$PONYSAY_SHELL_LINES" = "" ]; then - PONYSAY_SHELL_LINES=2 - fi head --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES )) } + function htrunctail + { + tail --lines=$(( `stty size <&2 | cut -d ' ' -f 1` - $PONYSAY_SHELL_LINES )) + } 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 | tac | htrunc | tac + exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunctail else - exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunc + exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc | htrunchead fi else exec "$cmd" -f "$pony" "${wrap:+-W$wrap}" | wtrunc -- cgit