https://github.com/aleclarson/cush-shell
Throwaway shell scripts
https://github.com/aleclarson/cush-shell
Last synced: 11 months ago
JSON representation
Throwaway shell scripts
- Host: GitHub
- URL: https://github.com/aleclarson/cush-shell
- Owner: aleclarson
- License: mit
- Created: 2021-04-12T20:08:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-12T20:11:19.000Z (about 5 years ago)
- Last Synced: 2025-03-28T02:50:48.456Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @cush/shell
[](https://www.npmjs.com/package/@cush/shell)
[](https://github.com/prettier/prettier)
[](https://paypal.me/alecdotbiz)
> Throwaway shell scripts
**Features:**
- Anything a shell script can do
- Piping
- Multiple lines
- Shebang
- Includes `set -e` automatically
- Optional blocking mode
- Cleans up after script finishes or when process exits
- Executed with [`@cush/exec`](https://www.npmjs.com/package/@cush/exec)
- Arguments are passed through (see readme for more info)
## Usage
```ts
import shell from '@cush/shell'
// Scripts can be indented if you like.
const script = `
#!/usr/bin/bash
ls | xargs -I {} echo {}
`
const proc = shell(script, (stdout, stderr) => {
// This callback is optional.
// See @cush/exec docs for more info.
})
// You can await the stdout.
const stdout = await proc
// Blocking mode
shell.sync(script)
```