mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-07 13:36:43 +01:00
25 lines
640 B
Bash
Executable file
25 lines
640 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
INSTALLDIR="$(dirname $( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))"
|
|
LIBDIR="$INSTALLDIR/lib/ponysay"
|
|
|
|
# The truncater executable
|
|
truncatercmd="$LIBDIR/truncater"
|
|
|
|
# Screen width
|
|
scrw=`(stty size <&2 || echo 0 0) | cut -d ' ' -f 2`
|
|
|
|
# Output trunction on width
|
|
function wtrunc {
|
|
if [[ "$PONYSAY_FULL_WIDTH" = 'yes' ]] || [[ "$PONYSAY_FULL_WIDTH" = 'y' ]] || [[ "$PONYSAY_FULL_WIDTH" = '1' ]] || [[ ! -f $truncatercmd ]]; then
|
|
cat
|
|
else
|
|
$truncatercmd $scrw
|
|
fi
|
|
}
|
|
|
|
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
|
export PERL_UNICODE=S
|
|
|
|
# Run ponysay
|
|
"$0.py" "$@" | wtrunc
|