From 62a3d88d58bc5be870587012d74e28d57529356e Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sat, 18 Aug 2012 20:10:46 +0200 Subject: [PATCH 1/2] Check if script is being launched in subshell or being redirected to file, and make -l to --onelist. This more or less depricates '--onelist' as flag --- ponysay.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ponysay.py b/ponysay.py index 800343ed..dcfb6b0a 100755 --- a/ponysay.py +++ b/ponysay.py @@ -46,6 +46,12 @@ Whether the program is execute in Linux VT (TTY) linuxvt = os.environ['TERM'] == 'linux' +''' +Whether the program is launched in subshell/beeing redirected +''' +redirected = not sys.stdout.isatty() + + ''' The directories where pony files are stored, ttyponies/ are used if the terminal is Linux VT (also known as TTY) ''' @@ -81,7 +87,7 @@ parser.add_argument( '--onelist', action = 'store_true', dest = 'onelist', parser.add_argument('-W', '--wrap', action = 'store', dest = 'wrap', help = 'specify the column when the message should be wrapped') parser.add_argument('-f', '--pony', action = 'append', dest = 'pony', help = 'select a pony (either a file name or a pony name)') parser.add_argument('-q', '--quote', nargs = '*', dest = 'quote', help = 'select a pony which will quote herself') -parser.add_argument('message', nargs = '?', help = 'message to ponysay') +parser.add_argument('message', nargs = '?', help = 'message to ponysay') args = parser.parse_args() # TODO implement if [ -t 0 ] && [ $# == 0 ]; then @@ -99,6 +105,10 @@ class ponysay(): Starts the part of the program the arguments indicate ''' def __init__(self, args): + if args.list and redirected: + args.list = False + args.onelist = True + if args.list: self.list() elif args.linklist: self.linklist() elif args.quoters: self.quoters() From a4385d7754fefd06be8bbc78a398f02d32e8c191 Mon Sep 17 00:00:00 2001 From: Elis Axelsson Date: Sat, 18 Aug 2012 20:31:50 +0200 Subject: [PATCH 2/2] made links to github stuff relative and cleaned the deps --- README.md | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index e27fb3ea..c79efb0f 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ First of all, you need `cowsay` from your local repositories. Obtain it from [here](http://www.nog.net/~tony/warez) if you wish to compile it yourself. This is often sufficient, but if is not you may be missing one of the standard packages: [bash](ftp://ftp.gnu.org/gnu/bash/), [coreutils](ftp://ftp.gnu.org/gnu/coreutils/) or [sed](ftp://ftp.gnu.org/gnu/sed/). -[Download](https://github.com/erkin/ponysay/downloads) or clone the project. +[Download](/erkin/ponysay/downloads) or clone the project. In the terminal, `cd` into the ponysay directory and `make && make install`. This will install ponysay into the $PREFIX (`/usr` by default, meaning you may need to `make install` as root, e.g. `sudo make install`.) @@ -46,7 +46,7 @@ This requires that you have the `fortune` utility installed. You can install it or just fetch the source code from [here](ftp://ftp.ibiblio.org/pub/linux/games/amusements/fortune/). You can try [this](http://www.reddit.com/r/mylittlelinux/comments/srixi/using_ponysay_with_a_ponified_fortune_warning/) script or -[ponypipe](https://github.com/maandree/ponypipe) to ponify fortunes. +[ponypipe](/maandree/ponypipe) to ponify fortunes. Edit your `~/.bashrc` and add this to the end of the file @@ -84,19 +84,13 @@ Dependencies ### Required runtime dependencies -`bash`: required for the main script [file: ponysay] - `cowsay`: this is a wrapper for cowsay -`coreutils`: the main script uses stty, cut, ls, cat, sort, readlink, pwd, head and tail - -`sed`: used to remove .pony from pony names when running `ponysay -l` and `ponysay -l` - -`perl`: required to run `ponysay -l` and `ponysay -L` +`python3`: Written in python3 ### Package building dependencies -`gcc`: used for compiling ponysaytruncater.c +`gcc`: used for compiling ponysaytruncater.c (???) `gzip`: used for compressing manpages @@ -110,13 +104,13 @@ FAQ __Q:__ The output looks like a mess in _(TTY/PuTTY/other)_! -__A:__ Unfortunately, there's nothing much we can do about it. See [issue 1](https://github.com/erkin/ponysay/issues/1). +__A:__ Unfortunately, there's nothing much we can do about it. See [issue 1](/erkin/ponysay/issues/1). __Q:__ You are missing _(my-favourite-pony)_! -__A:__ [Ask](https://github.com/erkin/ponysay/issues) and we'll add! +__A:__ [Ask](/erkin/ponysay/issues) and we'll add! __Q:__ Which programs do you use to generate the pony files? __A:__ The pony files are actually mostly a bunch of selected [browser ponies](http://web.student.tuwien.ac.at/~e0427417/browser-ponies/ponies.html) -that are generated into cow files via [img2xterm](https://github.com/rossy2401/img2xterm) or [util-say](https://github.com/maandree/util-say). +that are generated into cow files via [img2xterm](/rossy2401/img2xterm) or [util-say](/maandree/util-say).