# 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")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Ovsyanka83/pysh",
"name": "pysh",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7,<4.0",
"maintainer_email": "",
"keywords": "python,shell,bash,script,scripting,pysh",
"author": "Stanislav Zmiev",
"author_email": "szmiev2000@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/bf/e4/8279c009366f7471a6214831d6a4540c72885947f1bf8aef6f72c901c711/pysh-3.3.0.tar.gz",
"platform": null,
"description": "# pysh\n\nA library of small functions that simplify scripting in python\n\n## Installation\n\n```bash\npip install pysh\n```\n\n## Usage\n\n### sh\n\nRun a shell command and display the output:\n\n```python\nsh(\"git status\")\n```\n\nCapture the output of a shell command:\n\n```python\nres = sh(\"git status\", capture=True)\nprint(res.stdout)\n```\n\n### cd\n\nChange the current working directory:\n\n```python\ncd(\"path/to/dir\")\n```\n\nChange the current working directory temporarily:\n\n```python\nwith cd(\"path/to/dir\"):\n sh(\"git status\")\n```\n\n### env\n\nSet an environment variable:\n\n```python\nenv(var=\"value\")\n```\n\nSet an environment variable temporarily:\n\n```python\nwith env(PGPASSWORD=\"MyPassword\", PGUSER=\"postgres\"):\n sh(\"createdb -h localhost -p 5432 -O postgres mydb\")\n```\n\n### which\n\nChecks whether an executable/script/builtin is available:\n\n```python\ngit_is_installed = which(\"git\")\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library of small functions that simplify scripting in python",
"version": "3.3.0",
"split_keywords": [
"python",
"shell",
"bash",
"script",
"scripting",
"pysh"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "daeec3acf52f72a93c418b6f742f36c3c0de23acd0ad3b95821cc9f27b19bdff",
"md5": "6bdf22e61249cbeaa4757e88c51a5ce8",
"sha256": "853826fd38cfdb3bc2841051983abb7b10b37d94f60727574e4465c7a671276d"
},
"downloads": -1,
"filename": "pysh-3.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6bdf22e61249cbeaa4757e88c51a5ce8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7,<4.0",
"size": 3160,
"upload_time": "2023-01-15T15:49:15",
"upload_time_iso_8601": "2023-01-15T15:49:15.532060Z",
"url": "https://files.pythonhosted.org/packages/da/ee/c3acf52f72a93c418b6f742f36c3c0de23acd0ad3b95821cc9f27b19bdff/pysh-3.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bfe48279c009366f7471a6214831d6a4540c72885947f1bf8aef6f72c901c711",
"md5": "d4f36218e3b99c48464918d2ccf7b619",
"sha256": "51ef7828d0de07376f1dc3802c9e3f7790eaca60193d07717a6e606ed5b0e062"
},
"downloads": -1,
"filename": "pysh-3.3.0.tar.gz",
"has_sig": false,
"md5_digest": "d4f36218e3b99c48464918d2ccf7b619",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7,<4.0",
"size": 3080,
"upload_time": "2023-01-15T15:49:16",
"upload_time_iso_8601": "2023-01-15T15:49:16.789224Z",
"url": "https://files.pythonhosted.org/packages/bf/e4/8279c009366f7471a6214831d6a4540c72885947f1bf8aef6f72c901c711/pysh-3.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-15 15:49:16",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "Ovsyanka83",
"github_project": "pysh",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pysh"
}