Skip to content

vivianludrick/ai-command-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 AI Command Generator

A smart CLI tool that generates and executes terminal commands based on natural language descriptions.

Command Generator Demo

Overview

AI Command Generator uses Gemini AI to turn natural language descriptions into executable shell commands. Simply describe what you want to do, and the tool will generate the appropriate command for you.

Features

  • 🧠 Generate commands from natural language descriptions
  • 🔄 Modify existing commands by describing changes
  • ⚡ Interactive TUI mode with command preview
  • 📋 Copy commands to clipboard
  • 🚀 Direct execution mode with --cli flag

Installation

Prerequisites

  • Go 1.18 or higher
  • Gemini API key (required)
  • Make(optional)

Getting a Gemini API Key

⚠️ Important: This project requires your own Gemini API key to function.

  1. Visit Google AI Studio
  2. Create or sign in to your Google account
  3. Generate a new API key
  4. Save this key securely - you'll need it to build the application

Building from source

  1. Clone the repository:

    git clone https://github.com/vivalchemy/ai-command-generator.git
    cd ai-command-generator
  2. Set your Gemini API key in the Makefile:

    Note: If you don't have make installed, then copy the command below to your terminal and run it.

    # Replace <your_gemini_api_key> with your actual API key
    build:
       go build -o ai -ldflags "-X 'main.apiKey=YOUR_ACTUAL_API_KEY_HERE'" main.go
  3. Build the application(skip if you don't have make installed):

    make build

    This will create an executable named ai in your project directory.

  4. (Optional) Add to your PATH:

    cp ai ~/.local/bin
  5. Add ~/.local/bin to your PATH environment variable:

    export PATH="$PATH:~/.local/bin"

Usage

Basic Usage

ai "list all files in the current directory, including hidden files"

Modifying existing commands

ai "ls -l only show files larger than 1MB and sort by size"

Direct execution mode

Use the --cli flag to execute the generated command immediately without the interactive UI:

ai --cli "find all jpg files in the current directory"

Usage Examples

Finding files

ai "find all log files modified in the last 24 hours"

Processing text

ai "extract all email addresses from a text file"

System operations

ai "show CPU and memory usage sorted by usage"

Network commands

ai "scan open ports on localhost"

How It Works

  1. The tool takes your description as input
  2. Sends it to Gemini AI with a specialized system prompt
  3. Gets back a proper shell command
  4. Displays the command with options to:
    • Execute the command
    • Copy to clipboard
    • Quit without action

Project Structure

.
├── main.go               # Main application code
├── Makefile              # Build configuration
├── assets/               # Project assets
│   └── demo.gif          # Demo animation
├── README.md             # This file
└── .env.example          # Example environment variables

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Credits

Contribution

Contributions are welcome! Please feel free to submit a Pull Request.

About

A smart CLI tool that generates and executes terminal commands based on natural language descriptions.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors