Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zmievsa/pysh
A library of small functions that simplify scripting in python
https://github.com/zmievsa/pysh
bash pysh python script scripting shell
Last synced: 18 days ago
JSON representation
A library of small functions that simplify scripting in python
- Host: GitHub
- URL: https://github.com/zmievsa/pysh
- Owner: zmievsa
- License: mit
- Created: 2022-03-19T05:16:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-28T15:28:23.000Z (about 1 year ago)
- Last Synced: 2024-09-16T10:48:42.806Z (about 2 months ago)
- Topics: bash, pysh, python, script, scripting, shell
- Language: Python
- Homepage:
- Size: 85.9 KB
- Stars: 19
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pysh
A library of small functions that simplify scripting in python
## Installation
```bash
pip install pysh
```## Usage
### sh
Run a shell command and display the output:
```python
sh("git status")
```Capture the output of a shell command:
```python
res = sh("git status", capture=True)
print(res.stdout)
```### cd
Change the current working directory:
```python
cd("path/to/dir")
```Change the current working directory temporarily:
```python
with cd("path/to/dir"):
sh("git status")
```### env
Set an environment variable:
```python
env(var="value")
```Set an environment variable temporarily:
```python
with env(PGPASSWORD="MyPassword", PGUSER="postgres"):
sh("createdb -h localhost -p 5432 -O postgres mydb")
```### which
Checks whether an executable/script/builtin is available:
```python
git_is_installed = which("git")
```