shshsh 🐍❤️🐚
Shshsh is a bridge connects python and shell.
- A simple way to write shell in python.
- Flexable.
- Support directly chain a python function in pipe.
Installation
To install shshsh with pip, run: pip install shshsh
To install shshsh with conda, run: conda install shshsh -c conda-forge
To install shshsh from source, clone the repository and run: pip install poetry;poetry install
⚠️ If you are using python3.8: Be very careful with python function Pipe, there are known bugs!
Basic Usage
You can use I >> "[command]" or Sh("[command]")in any Python project.
Here's an example of getting all file which name contains "test":
from shshsh import I
for filename in I >> "ls" | "grep test":
print(filename)
Also, you can safely pass parameter without command injection, shshsh will help you escape all bash control character:
from shshsh import I
from sys import stdout
res = (I >> "echo #{}") % "dangerous; cat /etc/passwd" | stdout
res.wait()
# dangerous; cat /etc/passwd
Python function or iterable can be part of chain, you no longer have to search Google (or chatgpt) repeatedly to write sed or awk😇:
from shshsh import I
from sys import stdout
# as map function
def add_suffix(line: str) -> str:
return line + ".py"
res = I >> "ls -alh" | add_suffix | "grep test" | stdout
res.wait()
# as data source
def data_source():
for i in range(10):
yield f"test{i}"
res = I >> data_source() | "grep test1" | stdout
res.wait()
Metadata
Release files for shshsh 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shshsh-1.0.1.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shshsh-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.1 kB
Release files / shshsh-1.0.1.tar.gz
| Download URL | shshsh-1.0.1.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56aeb13394339c755f2a04261f471212a888053858a4774cbcb66d2ffe1d22b5
|
|
BLAKE2b-256 checksum How to use checksums |
10d606652d58501b19b8fd546386f1167f747c9dc3c5633e22ec0e1091010f0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.9.13 Linux/6.4.6-arch1-1
|
Release files / shshsh-1.0.1-py3-none-any.whl
| Download URL | shshsh-1.0.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d0155cb55ea751eac2d2c6401061b349562fdc8cdac23854e09c7270b6062c9
|
|
BLAKE2b-256 checksum How to use checksums |
49dfb30dee2ac9a32a90054a4473a6c3e2de0797e845a34f9210f8b9c3863ec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.9.13 Linux/6.4.6-arch1-1
|