task.sh turns natural language task descriptions into safe shell command suggestions using OpenAI. The CLI is designed for cross-platform usage (Linux, macOS) and emphasizes safety, observability, and customization.
task gensubcommand with--shellselection (bash,zsh).- Verbose mode prints raw AI output and explanations.
- Regex-based command safety filters.
- Optional
TASK_SH_FAKE_RESPONSEenvironment variable for deterministic tests.
- Rust toolchain (via rustup).
- OpenAI API key with access to GPT-3.5 (or compatible) models.
git clone https://github.com/barledge/task.sh.git
cd task.sh
cargo install --path .
cp .env.example .envEdit .env and set OPENAI_API_KEY to your secret key.
# Generate a bash command with explanation
task gen "list large files" --shell bash -v
# Pipe input via stdin
echo "list staged changes" | task gen --verbose
# Use the fake response mode for testing/demos
TASK_SH_FAKE_RESPONSE=$'Command: ls\nExplanation: list files' task gen "anything"Inspect all options:
sh --helpOPENAI_API_KEY: Required for live generation.TASK_SH_FAKE_RESPONSE: Optional string that substitutes the OpenAI response for testing.
cargo fmt
cargo clippy --all-targets
cargo testscripts/build-release.sh
scripts/publish.shFor cross-compilation (requires cargo-zigbuild):
scripts/build-cross.sh x86_64-unknown-linux-gnu
scripts/build-cross.sh x86_64-pc-windows-gnu
scripts/build-cross.sh aarch64-apple-darwinThe mdBook-based docs live in docs/.
cargo install mdbook
mdbook build docsPublish to task.sh/docs or serve locally with mdbook serve docs.
- Fork the repository and create a feature branch.
- Add tests covering new functionality.
- Run
cargo fmt,cargo clippy, andcargo testbefore submitting a PR. - Submit a PR with a concise description of the changes.
Licensed under the MIT License.