danielgreve / from-sh-import-all

An interactive pseudo-shell embedded in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Python as a pseudo-shell with sh

How to run

First confirm the sh module is installed, or install with pip.

python -i from-sh-import-all.py

# Alternatively, for filename tab completion
ipython -i from-sh-import-all.py

Examples

>>> ls()
LICENCE.md              README.md               from-sh-import-all.py

>>> git.init("README.md")

>>> echo("Hello")
Hello

>>> 

Why would you want to do this?

Honestly, you likely would not. Python syntax is terse, but not terse enough for a great shell experience. Plus, sh does not implement interactive applications yet, so vim and the like would not be available unless you defined functions for them like so:

def vim(filename)
    os.system("vim {}".format(filename))

Altogether, IPython provides a better interactive experience for system shell usage along with Python. However, sh is a godsend for scripting with shell commands.

Further reading

About

An interactive pseudo-shell embedded in Python

License:Other


Languages

Language:Python 100.0%