aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay20
1 files changed, 14 insertions, 6 deletions
diff --git a/ponysay b/ponysay
index 2f60ab3..e50b0b1 100755
--- a/ponysay
+++ b/ponysay
@@ -63,18 +63,26 @@ 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
+ 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
}
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
+ 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