AI-powered bash command generator that converts natural language descriptions into executable shell commands
Project description
Sprinkle
AI-powered bash command generator that converts natural language descriptions into executable shell commands
Abstract
Sprinkle is a Python-based command-line tool that leverages Google's Gemini AI to translate natural language descriptions into syntactically correct bash commands. It supports both simple command generation and template-based substitution for complex multi-step operations. The tool can either output commands for review or execute them directly, with an optional interactive editor for command refinement.
Installation
From PyPI (Recommended)
# Install with pip
pip install sprinkle
# Or install with pipx (recommended for CLI tools)
pipx install sprinkle
Prerequisites
- Python 3.12 or higher
- Google Gemini API key
Setup
- Set up your Google Gemini API key:
export GOOGLE_API_KEY="your-gemini-api-key-here"
Development Installation
If you want to contribute or modify the code:
- Clone the repository:
git clone <repository-url>
cd sprinkle
- Install in development mode:
pip install -e .
Usage
Basic Command Generation
Convert natural language descriptions to bash commands:
# Generate and execute a command
sprinkle "list all files in current directory"
# Output command without executing (safe mode)
sprinkle -o "find all python files larger than 1kb"
# Verbose output to see the AI reasoning process
sprinkle -v -o "count lines in all python files"
Template-Based Commands
Use {{}} syntax for complex multi-step operations:
# Generate compound commands with AI substitution
sprinkle -o "{{find all python files}} and {{count the lines}}"
# More complex example
sprinkle -o "{{create backup directory}} then {{copy all config files to backup}}"
Interactive Editing
Use the editor mode to review and modify commands before execution:
# Open interactive editor before execution
sprinkle -e "compress all log files older than 30 days"
Command Line Options
-h, --help: Show help message and exit-v, --verbose: Enable verbose output to see AI processing steps-o, --output: Output commands to stdout instead of executing them-e, --editor: Open interactive editor to modify commands before execution
Examples
File Operations
# List files with details
sprinkle -o "show detailed information about all files including hidden ones"
# Output: ls -la
# Find and process files
sprinkle -o "find all JSON files and validate their syntax"
# Output: find . -name "*.json" -exec python -m json.tool {} \; > /dev/null
# Backup with timestamp
sprinkle -o "create a backup of the config directory with current timestamp"
# Output: cp -r config config_backup_$(date +%Y%m%d_%H%M%S)
System Administration
# Process management
sprinkle -o "kill all processes containing the word nginx"
# Output: pkill -f nginx
# Disk usage analysis
sprinkle -o "show disk usage of all directories sorted by size"
# Output: du -sh */ | sort -hr
Template-Based Complex Operations
# Multi-step file processing
sprinkle -o "{{find all log files older than 7 days}} and {{compress them with gzip}}"
# Output: find . -name "*.log" -mtime +7 and gzip
# Conditional operations
sprinkle -o "{{check if docker is running}} and {{start nginx container if it exists}}"
# Output: systemctl is-active docker and docker start nginx 2>/dev/null || echo "nginx container not found"
Features
- Natural Language Processing: Convert plain English descriptions to bash commands
- Template Substitution: Use
{{}}syntax for complex multi-part commands - Safety Mode: Output commands for review before execution (
-oflag) - Interactive Editing: Modify generated commands before execution (
-eflag) - Verbose Mode: See AI reasoning and processing steps (
-vflag) - Error Handling: Automatic inclusion of appropriate error handling and safety flags
- Command Chaining: Intelligent use of
&&,;,|, and||operators - POSIX Compatibility: Generates portable commands when possible
Safety Notes
- Always use the
-oflag first to review generated commands before execution - The tool can execute potentially destructive commands - exercise caution
- Set appropriate file permissions and run in appropriate directories
- Consider using the interactive editor (
-e) for complex operations
Requirements
The application requires the following Python packages:
langchain>=0.3.26langchain-google-genai>=1.0.0pydantic>=2.11.7textual>=5.2.0
Environment Variables
GOOGLE_API_KEY: Required. Your Google Gemini API key for AI command generation.
License
This project is licensed under the terms specified in the project configuration.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sprinkle_ai-0.1.0.tar.gz.
File metadata
- Download URL: sprinkle_ai-0.1.0.tar.gz
- Upload date:
- Size: 43.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46665857b75c662a0a954f2308daa3abd6771bbd8f1eaa3a9d08a579353fc0f7
|
|
| MD5 |
0174ccd2ae4e432d139259162f6a936c
|
|
| BLAKE2b-256 |
37e32af12b66d9c139b2e5f1b96cfb3938d87bfc874a1758f022ae562d81965d
|
Provenance
The following attestation bundles were made for sprinkle_ai-0.1.0.tar.gz:
Publisher:
python-publish.yml on yairvogel/sprinkle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sprinkle_ai-0.1.0.tar.gz -
Subject digest:
46665857b75c662a0a954f2308daa3abd6771bbd8f1eaa3a9d08a579353fc0f7 - Sigstore transparency entry: 348775754
- Sigstore integration time:
-
Permalink:
yairvogel/sprinkle@17f9c6639bba67a095848df2baf1c43ee3bcb90b -
Branch / Tag:
refs/tags/0.1.0-alpha.1 - Owner: https://github.com/yairvogel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@17f9c6639bba67a095848df2baf1c43ee3bcb90b -
Trigger Event:
release
-
Statement type:
File details
Details for the file sprinkle_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sprinkle_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c20a4d07fc6e4682d528ed5001192228fa1572196f4a7c33ab52609ccf2547e
|
|
| MD5 |
aa53e148fe8ff4ec0abea9acc28f29d6
|
|
| BLAKE2b-256 |
a06478e14147a2f9baa14a028c4c8847bec525f1d1e6d5e6fca6ed346a29c0e4
|
Provenance
The following attestation bundles were made for sprinkle_ai-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on yairvogel/sprinkle
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sprinkle_ai-0.1.0-py3-none-any.whl -
Subject digest:
4c20a4d07fc6e4682d528ed5001192228fa1572196f4a7c33ab52609ccf2547e - Sigstore transparency entry: 348775782
- Sigstore integration time:
-
Permalink:
yairvogel/sprinkle@17f9c6639bba67a095848df2baf1c43ee3bcb90b -
Branch / Tag:
refs/tags/0.1.0-alpha.1 - Owner: https://github.com/yairvogel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@17f9c6639bba67a095848df2baf1c43ee3bcb90b -
Trigger Event:
release
-
Statement type: