Skip to content

SleepInfinity/ai-command-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-command-generator

Powered by Google's Gemini API, this tool helps you generate, edit, and execute shell commands on the go — right from your terminal.


🧠 What is it?

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.


✨ Features

  • ✅ 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)

🚀 Installation

git clone https://github.com/SleepInfinity/ai-command-generator.git
cd ai-command-generator
pip install -r requirements.txt
cp .env.example .env
nano .env

Edit the .env file and paste your API key from Google AI Studio:

GEMINI_API_KEY=AIxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

🧪 Usage

Basic 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]

🔧 Make it easier to use with an alias:

Run this command and specify your shell configuration file (~/.bashrc, ~/.zshrc, etc.):

echo "alias ai='python3 $(pwd)/ai.py'" >> ~/.bashrc

Then restart your terminal, and you can simply run:

ai "command to update the system"

⚠️ Disclaimer

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.


🤝 Contribute

Contributions are welcome! Feel free to:

  • Open issues for bugs, feature suggestions, or compatibility problems
  • Submit pull requests to improve the tool

About

Generate and run Linux commands in your terminal using AI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages