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 --- Makefile | 2 ++ manpage.1 | 18 ++++++++++++++++-- ponysay | 17 ++++++++++++----- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 467a000..194fa29 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ install: all mkdir -p "$(DESTDIR)/usr/share/man/man1" install "manpage.1" "$(DESTDIR)/usr/share/man/man1/ponysay.1" + ln -sf "ponysay.1" "$(DESTDIR)/usr/share/man/man1/ponythink.1" uninstall: rm -fr "$(DESTDIR)/usr/share/ponies" @@ -36,6 +37,7 @@ uninstall: unlink "$(DESTDIR)/usr/share/licenses/ponysay/COPYING" unlink "$(DESTDIR)/usr/share/bash-completion/completions/ponysay" unlink "$(DESTDIR)/usr/share/man/man1/ponysay.1" + unlink "$(DESTDIR)/usr/share/man/man1/ponythink.1" clean: rm -r "ponysaytruncater" diff --git a/manpage.1 b/manpage.1 index d5b8ec9..57c4222 100644 --- a/manpage.1 +++ b/manpage.1 @@ -22,6 +22,10 @@ ponysay \- A cowsay wrapper with ponies .RI [ options ] .RI [ message ] .br +.B ponythink +.RI [ options ] +.RI [ message ] +.br .SH DESCRIPTION .PP .\" TeX users may be more comfortable with the \fB\fP and @@ -33,6 +37,8 @@ word-wraps the message given at about 40 columns, and prints the pony saying the .PP If no arguments are provided, the program only accepts standard input piped from another program, a file or either here documents or here strings (see man bash(1) for details on here document/string.) +.PP +\fBponythink\fP is to \fIponysay\fP as \fIcowthink\fP is to \fIcowsay\fP. .SH OPTIONS A summary of options is included below. .TP @@ -54,8 +60,16 @@ The screen column where the message should be wrapped .TP .B PONYSAY_BOTTOM Under TTY (Linux VT), if the output is larger the the screen's height, only the beginning is -printed, leaving 2 blank lines. If you want the buttom to be printed rather the the beginning +printed, leaving two blank lines. If you want the buttom to be printed rather the the beginning you can export \fBPONYSAY_BOTTOM\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP. +.B PONYSAY_SHELL_LINES +Under TTY (Linux VT), if the output is larger the the screen's height, two lines are left blank. +If you want moer, or less, blank lines you can export \fBPONYSAY_SHELL_LINES\fP with the value +of how many blank lines you want. Naturally this takes effect if the output is not actually larger +than the screen. +.B PONYSAY_FULL_WIDTH +You can export \fBPONYSAY_FULL_WIDTH\fP with the value \fIno\fP, \fIn\fP or \fI0\fP, if you +do not want the output to be truncated on the width to fit the terminal. .SH BUG Bugs can be reported in <\fBhttps://github.com/erkin/ponysay/issues\fP>. .SH SEE ALSO @@ -86,4 +100,4 @@ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE .br TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION .PP - 0. You just DO WHAT THE FUCK YOU WANT TO. +0. You just DO WHAT THE FUCK YOU WANT TO. 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 --- manpage.1 | 3 +++ ponysay | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manpage.1 b/manpage.1 index 57c4222..ec35533 100644 --- a/manpage.1 +++ b/manpage.1 @@ -70,6 +70,9 @@ than the screen. .B PONYSAY_FULL_WIDTH You can export \fBPONYSAY_FULL_WIDTH\fP with the value \fIno\fP, \fIn\fP or \fI0\fP, if you do not want the output to be truncated on the width to fit the terminal. +.B PONYSAY_TRUNCATE_HEIGHT +Export \fBPONYSAY_TRUNCATE_HEIGHT\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP, if you +want to truncate the output on the height even if you are not running \fIponysay\fP under TTY. .SH BUG Bugs can be reported in <\fBhttps://github.com/erkin/ponysay/issues\fP>. .SH SEE ALSO 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(-) 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 615f84ca5c6804a1d599433601480874c3877fd7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 5 Jul 2012 11:00:09 +0200 Subject: derp --- manpage.1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/manpage.1 b/manpage.1 index ec35533..e35603f 100644 --- a/manpage.1 +++ b/manpage.1 @@ -61,17 +61,20 @@ The screen column where the message should be wrapped .B PONYSAY_BOTTOM Under TTY (Linux VT), if the output is larger the the screen's height, only the beginning is printed, leaving two blank lines. If you want the buttom to be printed rather the the beginning -you can export \fBPONYSAY_BOTTOM\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP. +you can export \fIPONYSAY_BOTTOM\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP. +.TP .B PONYSAY_SHELL_LINES Under TTY (Linux VT), if the output is larger the the screen's height, two lines are left blank. -If you want moer, or less, blank lines you can export \fBPONYSAY_SHELL_LINES\fP with the value +If you want more, or less, blank lines you can export \fIPONYSAY_SHELL_LINES\fP with the value of how many blank lines you want. Naturally this takes effect if the output is not actually larger than the screen. +.TP .B PONYSAY_FULL_WIDTH -You can export \fBPONYSAY_FULL_WIDTH\fP with the value \fIno\fP, \fIn\fP or \fI0\fP, if you +You can export \fIPONYSAY_FULL_WIDTH\fP with the value \fIno\fP, \fIn\fP or \fI0\fP, if you do not want the output to be truncated on the width to fit the terminal. +.TP .B PONYSAY_TRUNCATE_HEIGHT -Export \fBPONYSAY_TRUNCATE_HEIGHT\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP, if you +Export \fIPONYSAY_TRUNCATE_HEIGHT\fP with the value \fIyes\fP, \fIy\fP or \fI1\fP, if you want to truncate the output on the height even if you are not running \fIponysay\fP under TTY. .SH BUG Bugs can be reported in <\fBhttps://github.com/erkin/ponysay/issues\fP>. -- cgit