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