diff options
author | Mattias Andrée <maandree@operamail.com> | 2012-07-05 09:24:29 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2012-07-05 09:24:29 +0200 |
commit | 2cc95ba021f4f295d974f51f5a4349aa370f3317 (patch) | |
tree | 820d035a06c339e229f976dd481a331373248f0b | |
parent | 348c0084a892b6967249e26a40f529301f7172e4 (diff) | |
download | ponysay-2cc95ba021f4f295d974f51f5a4349aa370f3317.tar.gz ponysay-2cc95ba021f4f295d974f51f5a4349aa370f3317.tar.bz2 ponysay-2cc95ba021f4f295d974f51f5a4349aa370f3317.zip |
using stty and cut (coreutils) instead of tput (ncurses) for getting terminal width
-rwxr-xr-x | ponysay | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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 } |