aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xponysay3
-rwxr-xr-xponysay.py14
-rwxr-xr-xponysay.sh18
3 files changed, 17 insertions, 18 deletions
diff --git a/ponysay b/ponysay
index 99292cc..891ec7f 100755
--- a/ponysay
+++ b/ponysay
@@ -19,4 +19,7 @@ function wtrunc {
fi
}
+# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
+export PERL_UNICODE=S
+
"$0.py" "$@" | wtrunc
diff --git a/ponysay.py b/ponysay.py
index 23e8f39..1714e77 100755
--- a/ponysay.py
+++ b/ponysay.py
@@ -41,11 +41,17 @@ HOME = os.environ['HOME']
'''
+Whether the program is execute in Linux VT (TTY)
+'''
+linuxvt = os.environ['TERM'] == 'linux'
+
+
+'''
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
'''
ponydirs = []
-if os.environ['TERM'] == 'linux': _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
-else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
+if linuxvt: _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
+else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
for ponydir in _ponydirs:
if os.path.isdir(ponydir):
ponydirs.append(ponydir)
@@ -320,9 +326,11 @@ class ponysay():
pony = self.__getponypath(args.pony)
- if "think.py" in __file__: cmd = 'cowthink'
+ if 'think.py' in __file__: cmd = 'cowthink'
else: cmd = 'cowsay'
+ if linuxvt:
+ print('\033[H\033[2J', end='')
os.system(cmd + (' -W ' + args.wrap if args.wrap is not None else '') + ' -f ' + pony + ' \'' + msg + '\'')
diff --git a/ponysay.sh b/ponysay.sh
index 10aa32a..27c0dce 100755
--- a/ponysay.sh
+++ b/ponysay.sh
@@ -53,25 +53,19 @@ ponyquotes() {
# Function for printing the ponies and the message
say() {
- # Ponies use UTF-8 drawing characters. Prevent a Perl warning.
- export PERL_UNICODE=S
-
- # Clear screen in TTY
- ( [ "$TERM" = "linux" ] || [ "$TERM" = "-linux-" ] ) && echo -ne '\e[H\e[2J'
-
# Set PONYSAY_SHELL_LINES to default if not specified
[ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2
-
+
# Height trunction, show top
function htrunchead {
head --lines=$(( $scrh - $PONYSAY_SHELL_LINES ))
}
-
+
# Height trunction, show bottom
function htrunctail {
tail --lines=$(( $scrh - $PONYSAY_SHELL_LINES ))
}
-
+
# Simplification of customisation of cowsay
if [ $customcmd = 0 ]; then
function cowcmd {
@@ -128,12 +122,6 @@ fi
# Parse options
while getopts "f:W:Llhvq" OPT; do
case ${OPT} in
- v) version; exit ;;
- h) usage; exit ;;
- f) ponies+=( $OPTARG ) ;;
- l) list; exit ;;
- L) linklist; exit ;;
- W) wrap="$OPTARG" ;;
q) shift $((OPTIND - 1)); ponyquotes "$*"; exit ;;
\?) usage >&2; exit 1 ;;
esac