Skip to content

PrajwalG7/search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” search โ€“ AI Powered Shell Command Generator & Explainer for Terminal

A lightweight Python-based CLI tool that uses Google Gemini to generate and explain shell commands based on user input. No more browser detours during development. Just search and get the results instantly.

"Who likes to visit the browser every time? ๐Ÿ™‚"


โœจ Features

  • ๐Ÿง  Generates and explains CLI commands in a single line.
  • ๐Ÿ“˜ Gives a usage example for better understanding.
  • โšก Uses gemini-1.5-flash-latest (Google Gemini API) for fast results.
  • โฑ๏ธ Displays time taken for the response in milliseconds.
  • ๐Ÿ–ฅ๏ธ Works fully within your terminal โ€” no context switching.
  • โ“ Prints usage help if no command is passed.

๐Ÿš€ Example Usage

search git commands to configure username and email globally

Output:

It sets the username and email used for Git commits globally, preventing you from having to specify them for each repository;  `git config --global user.name "Your Name" && git config --global user.email "your.email@example.com"`

โœจ Time taken: 2524 ms

โš™๏ธ Installation

1. Install the required Python package

Ensure Python 3+ is installed:

pip install google-generativeai

or

pip install -r requirements.txt

2. Add your Gemini API Key

  • Generate new API key from Google AI Studio
  • Open .zshrc or .bash depending on your system.
  • Add this line then save the file and reload the terminal.
export GEMINI_API_KEY="your-gemini-api-key"
  • Confirm it worked (gives API key as output)
echo $GEMINI_API_KEY

3. Rename your script (with no extension for clean usage)

mv search.py search

4. Make the script executable

chmod +x search

5. Move it to your $PATH to use it globally and reload the terminal

sudo mv search /usr/local/bin/

Now you can call it like any other shell command:

search docker stop $(docker ps -q)

๐Ÿ“‚ Project Structure

search/
โ”œโ”€โ”€ search.py            # Python script
โ””โ”€โ”€ README.md            # Project documentation
โ””โ”€โ”€ requirements.txt     # Dependencies

๐Ÿง  How It Works

  1. Uses sys.argv to collect the shell command from your input
  2. Calls Gemini API's generate_content() with a natural prompt
  3. Displays the explanation and example usage with response time in ms

If no input is passed:

search

You'll see:

Usage: search <your-command>

๐Ÿ“š Examples

search git reset --hard
search how to install nodemon globally

๐Ÿง‘โ€๐Ÿ’ป Built With

  • ๐Ÿ Python 3
  • ๐Ÿ”ฎ Google Gemini API (google-generativeai)
  • ๐Ÿ’ก Developer laziness ๐Ÿ˜„ (the good kind)

๐Ÿ“ซ Contact

Made with โค๏ธ and โ˜•๏ธ by Prajwal Gaikwad

If this tool saved you a trip to Browser, drop a โญ!

About

AI-Powered Command Generator & Explainer for Terminal

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages