Skip to main content

prs is a utility that allows you to use Python list comprehensions in shell commands.

Project description


prs is a small utility that lets you pipe things to Python and process them in a list comprehension.

If you've ever wished you could manipulate items in your shell with a Python list comprehension, prs is for you.


Just `pip install prs`.


prs is simple. You pipe stuff into it from the shell, it exposes whatever is piped as a list called `i` (without final
newlines) to a script, and expects the script to return either a string or an iterable to a variable called `o`. That
variable is then printed to stdout, so you can pipe it to `sh` for execution.

$ ls -1

$ ls -1 | prs "o = [l.lower() for l in i]"

Multiple lines can be separated by a semicolon.

Various libraries are already imported (but feel free to import your own):

* os
* sys
* pathlib.Path


Append `.bak` to all files in the current directory:

$ ls -1 | prs "o = ['mv {} {}.bak'.format(l, l) for l in i if Path(l).is_file()]"
mv setup.cfg setup.cfg.bak

Concatenate all entries into one:

02:28:39 $ ls -1 | prs "o = 'touch ' + ' '.join(i)"
touch LICENSE prs setup.cfg

Completely ignore all input:

02:29:35 $ ls -1 | prs "o = 'hi'"

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for prs, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size prs-0.0.3-py2-none-any.whl (4.6 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size prs-0.0.3-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size prs-0.0.3.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page