Powered by Google's Gemini API, this tool helps you generate, edit, and execute shell commands on the go — right from your terminal.
ai-command-generator uses the Gemini AI API to generate Linux shell commands based on natural language input. It types the command directly into your terminal, allowing you to modify it if needed before execution.
- ✅ Free to use Gemini API
- ⌨️ Auto-types the command in your terminal (press Enter to run, edit inline, or Ctrl+C to cancel)
- ⚡ Choose between different Gemini models (e.g.,
gemini-2.0-flash,gemini-2.5-pro) - 🖥️ Optionally includes system info (like distro, shell, and current directory) to personalize command generation
- 🗂️ Caching for faster responses to repeated questions (coming soon)
- 📜 Ask about previous commands using shell history (coming soon)
- 📖 Uses your local man pages to improve accuracy when asking about a specific command (coming soon)
- 🎛️ Supports multiple system prompt profiles (coming soon)
- 🛡 Safety warning for potential dangeurous or harmful commands
- 💬 Explain the generated command (coming soon)
git clone https://github.com/SleepInfinity/ai-command-generator.git
cd ai-command-generator
pip install -r requirements.txt
cp .env.example .env
nano .envEdit the .env file and paste your API key from Google AI Studio:
GEMINI_API_KEY=AIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxBasic usage:
python3 ai.py "command to update the system"Example output:
> sudo apt update && sudo apt upgrade -y
[Modify inline or press Enter to execute, Ctrl+C to cancel]
Run this command and specify your shell configuration file (~/.bashrc, ~/.zshrc, etc.):
echo "alias ai='python3 $(pwd)/ai.py'" >> ~/.bashrcThen restart your terminal, and you can simply run:
ai "command to update the system"Use this tool at your own risk.
The commands generated by ai-command-generator are powered by Google's Gemini AI API and are based on natural language interpretation. There is no guarantee that the output will be accurate, safe, or suitable for your specific system or use case.
We do not accept any liability for potential data loss, system damage, security issues, or other consequences resulting from the execution of AI-generated commands.
While this tool provides warnings when a dangerous command is generated, no filter is 100% safe and you should always review and understand the suggested commands before running them on your system.
Contributions are welcome! Feel free to:
- Open issues for bugs, feature suggestions, or compatibility problems
- Submit pull requests to improve the tool