mirror of
https://github.com/erkin/ponysay.git
synced 2025-02-14 16:44:23 +01:00
m misc
This commit is contained in:
parent
6e754c5509
commit
1dc737fb8b
3 changed files with 17 additions and 18 deletions
3
ponysay
3
ponysay
|
@ -19,4 +19,7 @@ function wtrunc {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ponies use UTF-8 drawing characters. Prevent a Perl warning.
|
||||||
|
export PERL_UNICODE=S
|
||||||
|
|
||||||
"$0.py" "$@" | wtrunc
|
"$0.py" "$@" | wtrunc
|
||||||
|
|
12
ponysay.py
12
ponysay.py
|
@ -40,11 +40,17 @@ The user's home directory
|
||||||
HOME = os.environ['HOME']
|
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)
|
The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY)
|
||||||
'''
|
'''
|
||||||
ponydirs = []
|
ponydirs = []
|
||||||
if os.environ['TERM'] == 'linux': _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
|
if linuxvt: _ponydirs = [HOME + '/.local/share/ponysay/ttyponies/', INSTALLDIR + '/share/ponysay/ttyponies/']
|
||||||
else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
|
else: _ponydirs = [HOME + '/.local/share/ponysay/ponies/', INSTALLDIR + '/share/ponysay/ponies/' ]
|
||||||
for ponydir in _ponydirs:
|
for ponydir in _ponydirs:
|
||||||
if os.path.isdir(ponydir):
|
if os.path.isdir(ponydir):
|
||||||
|
@ -320,9 +326,11 @@ class ponysay():
|
||||||
|
|
||||||
pony = self.__getponypath(args.pony)
|
pony = self.__getponypath(args.pony)
|
||||||
|
|
||||||
if "think.py" in __file__: cmd = 'cowthink'
|
if 'think.py' in __file__: cmd = 'cowthink'
|
||||||
else: cmd = 'cowsay'
|
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 + '\'')
|
os.system(cmd + (' -W ' + args.wrap if args.wrap is not None else '') + ' -f ' + pony + ' \'' + msg + '\'')
|
||||||
|
|
||||||
|
|
||||||
|
|
12
ponysay.sh
12
ponysay.sh
|
@ -53,12 +53,6 @@ ponyquotes() {
|
||||||
|
|
||||||
# Function for printing the ponies and the message
|
# Function for printing the ponies and the message
|
||||||
say() {
|
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
|
# Set PONYSAY_SHELL_LINES to default if not specified
|
||||||
[ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2
|
[ "$PONYSAY_SHELL_LINES" = "" ] && PONYSAY_SHELL_LINES=2
|
||||||
|
|
||||||
|
@ -128,12 +122,6 @@ fi
|
||||||
# Parse options
|
# Parse options
|
||||||
while getopts "f:W:Llhvq" OPT; do
|
while getopts "f:W:Llhvq" OPT; do
|
||||||
case ${OPT} in
|
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 ;;
|
q) shift $((OPTIND - 1)); ponyquotes "$*"; exit ;;
|
||||||
\?) usage >&2; exit 1 ;;
|
\?) usage >&2; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue