Natural Language to Bash Scripts π
ru.sh is a powerful command-line tool that turns your plain English requests into executable bash scripts using AI. Stop memorizing obscure flags and complex syntaxβjust say what you want, review the generated script, and run it.
- π£οΈ Natural Language Interface: Describe your task in plain English (e.g., "Find all files larger than 100MB and delete them").
- π‘οΈ Safety & Risk Analysis: Scripts are analyzed for risk levels (Safe to Critical) and syntax errors before execution.
- π Multi-Shell Support: Works with Bash, Zsh, Fish, PowerShell, and Cmd with automatic detection.
- π Script Explanation: Get a detailed breakdown of what a generated command does with the "Explain" feature.
- π Prompt Injection Protection: Built-in detection of malicious prompts and instruction overrides.
- π Execution History: Automatic logging of all prompts and generated scripts for auditing.
- π Model Presets: Choose between
fast,standard, andqualitymodels via OpenRouter. - π API Architecture: Documented integration architecture for developers.
- π οΈ Troubleshooting: Need help? See the Troubleshooting Guide.
- βοΈ Flexible Configuration: Manage API keys, models, usage limits, and timeouts via the CLI.
- π Usage Tracking: Monitor and set limits for your daily and monthly API usage to avoid surprises.
curl -sL https://ru-sh.dev/install | bashEnsure you have Rust installed.
git clone https://github.com/saint/ru.sh.git
cd ru.sh
cargo install --path crates/ru-cliYou need an OpenRouter API key.
# Recommended: Interactive Config
ru config set api-key sk-or-v1-your-key-here
# Alternative: Environment Variable
export OPENROUTER_API_KEY=sk-or-v1-your-key-hereBasic usage:
ru -p "Git commit all changes with the message 'wip'"Advanced Model Selection:
# Use a preset (fast, standard, quality)
ru -p "list files" --model fast
# Use a specific OpenRouter model ID
ru -p "refactor this script" --model-id anthropic/claude-3.5-sonnetDry Run: Review script and safety analysis without execution prompt.
ru -p "Delete all node_modules recursively" --dry-runSkip Confirmation (Use with Caution):
# Auto-execute Safe scripts only
ru -p "echo hello" -y
# Non-safe scripts require interactive confirmation (even with --force)
ru -p "rm -rf /" -y --forceru.sh automatically detects your current shell but can be configured for others:
| Shell | Binary | Platform |
|---|---|---|
| Bash | bash |
Unix / macOS / Windows (WSL) |
| Zsh | zsh |
Unix / macOS |
| Fish | fish |
Unix / macOS |
| Sh | sh |
Unix / macOS |
| PowerShell | pwsh |
Windows / Unix / macOS |
| Cmd | cmd |
Windows |
Override shell detection:
# Per-request
ru -p "list files" --shell zsh
# Persistent default
ru config set shell fish| Level | Description | Confirmation Required |
|---|---|---|
| Safe | Read-only or trivial commands | Optional (with -y) |
| Low | Minimal impact operations | Yes |
| Medium | Standard file/system changes | Yes |
| High | Potentially dangerous (e.g. rm, chmod) |
Yes (Requires typing "yes") |
| Critical | Highly destructive (e.g. rm -rf /) |
Yes (Requires typing "yes") |
ru.sh includes filters to detect and reject prompts that attempt to:
- Override system instructions
- Manipulate AI roles
- Inject malicious delimiters
All attempts and executions are logged to ~/.config/ru.sh/history.jsonl (Unix) or %AppData%\ru.sh\history.jsonl (Windows). Each record contains:
- The original prompt
- Generated script and its SHA-256 hash
- Safety analysis report
- Execution exit code and duration
Manage settings via the config subcommand:
| Key | Description | Default |
|---|---|---|
api-key |
OpenRouter API Key | None |
shell |
Default target shell | Auto-detected |
model |
Default preset (fast, standard, quality) | standard |
model-id |
Global custom model ID | None |
model.fast |
Custom model for fast preset | google/gemini-2.5-flash:nitro |
explain-verbosity |
Detail level (concise, verbose) | concise |
script-timeout |
Max execution time in seconds | 300 |
daily-limit |
Max daily API requests | 100 (warning) |
monthly-limit |
Max monthly API requests | 1000 (warning) |
Examples:
# Set explain verbosity to detailed
ru config set explain-verbosity verbose
# Change script timeout to 1 minute
ru config set script-timeout 60
# View all model presets
ru config modelsThis project is a Rust workspace:
crates/ru-cli: The CLI tool binary (ru).crates/ru-web: The Leptos web landing page.
# Build release binaries
cargo build --release
# Run unit tests
cargo test
# Start Web Dev Server (requires 'trunk')
cd crates/ru-web && trunk serveApache-2.0 License. See LICENSE for details.