Skip to content

zmievsa/pysh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pysh

A library of small functions that simplify scripting in python

Installation

pip install pysh

Usage

sh

Run 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)

cd

Change the current working directory:

cd("path/to/dir")

Change the current working directory temporarily:

with cd("path/to/dir"):
    sh("git status")

env

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")

which

Checks whether an executable/script/builtin is available:

git_is_installed = which("git")

About

A library of small functions that simplify scripting in python

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages