Convert natural language instructions to bash commands using Ollama
Project description
๐ Baish
Natural Language to Bash Commands using Ollama
Baish is a simple, elegant terminal application that converts natural language instructions into bash/linux commands using a local Ollama instance. Say goodbye to googling command syntax!
โจ Features
- ๐จ Beautiful Terminal UI - Rich, colorful interface with panels and prompts
- ๐ Ollama Integration - Works with any Ollama model locally
- โก Dual Modes - Interactive mode or single command execution
- ๐ก๏ธ Safety First - Built-in checks for potentially dangerous commands
- ๐ Real-time Execution - Live command output streaming
- ๐ Help System - Built-in help with
-hand/helpcommands
๐ Quick Start
Prerequisites
- Python 3.8+ with
uvpackage manager - Ollama installed and running locally
- A model downloaded in Ollama (e.g.,
ollama pull llama3.2)
Installation
Option 1: From PyPI (Recommended)
pip install baish
Option 2: From Source
git clone https://github.com/tcsenpai/baish.git
cd baish
uv pip install -e .
Option 3: Direct Execution
git clone https://github.com/tcsenpai/baish.git
cd baish
uv pip install rich click python-dotenv requests
python main.py "show my ip address"
Configuration
Create a .env file in your project directory:
OLLAMA_URL=http://localhost:11434
OLLAMA_MODEL=llama3.2:latest
๐ Usage
Command Line Interface
# Single command mode
baish "show my ip address"
baish "list files in current directory"
baish "check disk usage"
# Interactive mode
baish -i
# Show help
baish -h
# Direct execution (without installation)
python main.py "find python files"
uv run python main.py -i
Interactive Mode
$ baish -i
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ Baish - Natural Language to Bash โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
What would you like to do? > show my ip address
๐ค Thinking...
โโโโ Generated Command โโโโ
โ ip addr show โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
Execute this command? [Y/n]: y
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536...
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>...
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Command completed successfully
๐ฏ Examples
| Natural Language | Generated Command |
|---|---|
| "show my ip address" | ip addr show |
| "list files in current directory" | ls -la |
| "check disk usage" | df -h |
| "find python files" | find . -name "*.py" |
| "stop nginx service" | sudo systemctl stop nginx |
| "show running processes" | ps aux |
| "check memory usage" | free -h |
| "show network connections" | netstat -tuln |
๐ก๏ธ Safety Features
Baish includes built-in safety checks for potentially dangerous commands:
- Pattern Detection: Identifies risky commands like
rm -rf /,format,shutdown,curl | sh - User Confirmation: Always prompts before executing any command
- Command Preview: Shows exactly what will be executed in a highlighted panel
- Graceful Cancellation: Easy to cancel dangerous operations
- Debug Mode: Optional detailed logging for troubleshooting
Dangerous patterns detected:
- File system destruction (
rm -rf /,format,mkfs) - System control (
shutdown,reboot,init) - Privilege escalation risks (
chmod 777,chown root) - Remote execution (
curl | sh,wget | sh) - Fork bombs and system overload
โ๏ธ Configuration Options
Environment Variables
OLLAMA_URL- Ollama server URL (default:http://localhost:11434)OLLAMA_MODEL- Model to use (default:llama3.2:latest)BASH_DEBUG- Enable debug logging (optional)
Advanced Configuration
# Use remote Ollama instance
OLLAMA_URL=http://192.168.1.100:11434
# Use a specific model variant
OLLAMA_MODEL=codellama:7b-instruct
# Enable debug output
BASH_DEBUG=1
Model Recommendations
- Fast & Efficient:
llama3.2:latest,qwen2.5:7b,phi3:mini - More Capable:
llama3.1:8b,codellama:7b,qwen2.5:14b - Lightweight:
tinyllama:latest,phi3:mini - Code-Focused:
codellama:7b,deepseek-coder:6.7b
Note: Ensure your chosen model is installed in Ollama:
ollama pull llama3.2:latest
๐๏ธ Development
Setup Development Environment
git clone https://github.com/tcsenpai/baish.git
cd baish
# Copy and configure environment
cp .env.example .env
# Edit .env with your Ollama settings
# Install dependencies
uv pip install -e ".[dev]"
# Run tests
pytest
# Format code
black .
ruff check .
Project Structure
baish/
โโโ baish/
โ โโโ __init__.py
โ โโโ main.py # Package entry point
โโโ main.py # Direct execution entry point
โโโ pyproject.toml # Project configuration
โโโ .env # Configuration file
โโโ README.md # This file
Running Tests
pytest
Code Formatting
black .
ruff check .
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Ollama for the excellent local LLM platform
- Rich for the beautiful terminal UI
- Click for the CLI framework
๐ Support
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ง Email: [tcsenpai@discus.sh]
Made with โค๏ธ by tcsenpai
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 baish_assistant-0.1.0.tar.gz.
File metadata
- Download URL: baish_assistant-0.1.0.tar.gz
- Upload date:
- Size: 53.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f106dd5dadc46baa57f39e57b45b45eeda692b708c373213122c8220f65a942c
|
|
| MD5 |
f91dda4618a94bde06d4f521c2bcf889
|
|
| BLAKE2b-256 |
b8c1a6d52cc402473eab02a03d5d359d2ff20ec89919a87925950d866e5e8e23
|
File details
Details for the file baish_assistant-0.1.0-py3-none-any.whl.
File metadata
- Download URL: baish_assistant-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6557428401bb05c0136209909ec7b29e001b1ca720b89c6fb2f00ec5f8698164
|
|
| MD5 |
10e761aedfe9965dcd68539ddc4513bf
|
|
| BLAKE2b-256 |
07036259762416f4a4277ce74a3e96194f293ed24a14e89982bd23700108fb6e
|