A library of small functions that simplify scripting in python
pip install pyshRun a shell command and display the output:
sh("git status")Capture the output of a shell command:
res = sh("git status", capture=True)
print(res.stdout)Change the current working directory:
cd("path/to/dir")Change the current working directory temporarily:
with cd("path/to/dir"):
sh("git status")Set an environment variable:
env(var="value")Set an environment variable temporarily:
with env(PGPASSWORD="MyPassword", PGUSER="postgres"):
sh("createdb -h localhost -p 5432 -O postgres mydb")Checks whether an executable/script/builtin is available:
git_is_installed = which("git")