aboutsummaryrefslogtreecommitdiff
path: root/ponysay
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2012-07-03 09:57:53 +0200
committerMattias Andrée <maandree@operamail.com>2012-07-03 09:57:53 +0200
commit63e848a93f69e2028532cf89aa44eded21737cd5 (patch)
tree8eaa3160ac57d7a99c49a8e5ae4ec31cd4e63fd6 /ponysay
parent293f4d7403e55d9c597adc561081aff5aa0f621f (diff)
downloadponysay-63e848a93f69e2028532cf89aa44eded21737cd5.tar.gz
ponysay-63e848a93f69e2028532cf89aa44eded21737cd5.tar.bz2
ponysay-63e848a93f69e2028532cf89aa44eded21737cd5.zip
Ponies are truncated on height under TTY, leaving 2 lines for shell interaction. export PONYSAY_BOTTOM=1 to show bottom instread of top.
Diffstat (limited to 'ponysay')
-rwxr-xr-xponysay26
1 files changed, 22 insertions, 4 deletions
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