Skip to content

sarkarsaurabh27/gen-shell

Repository files navigation

🔍🐚 Gen-Shell

Leverage AI to generate shell commands from plain English.

stars issues forks license

📘 What is Gen-Shell?

Gen-Shell is a command-line interface (CLI) tool that uses the power of OpenAI's GPT-4 to interpret plain English descriptions of tasks and generate the corresponding shell commands. Inspired by projects like Zsh Codex and Codex-CLI by Microsoft, Gen-Shell aims to make the command line more accessible and efficient.

gen-shell

🚀 Features

  • AI-Powered: Utilizes OpenAI's GPT-4 for intelligent command generation.
  • Cross-Platform: Compatible with various Unix-based shells including Bash and Zsh.
  • User-Friendly: Easy-to-use for both beginners and experienced users.

📦 Installation

Prerequisites

  • Python 3.6+
  • OpenAI API key

Steps

  1. Clone the repository

    git clone https://github.com/yourusername/gen-shell.git
    cd gen-shell
  2. Setup virtual environment (Optional)

    python -m venv env
    source env/bin/activate  # Unix/macOS
    env\Scripts\activate  # Windows
  3. Install Gen-Shell

    pip install -e .
  4. Environment Configuration

    Set your OpenAI API key in your environment:

    export OPENAI_API_KEY="Your_OpenAI_API_Key"
  5. [Optional] Setup an Alias

    Setup gen-sell alias gs in bash profile:

    # if `.bash_profile` is your primary bash configuration file):
    echo "alias gs='gen-shell'" >> ~/.bash_profile
    source ~/.bash_profile
    
    # If you're using `.bashrc` predominantly (common on Linux systems), use:
    echo "alias gs='gen-shell'" >> ~/.bashrc
    source ~/.bashrc
    
    # Use this command to add the alias to your .zshrc:
    echo "alias gs='gen-shell'" >> ~/.zshrc
    source ~/.zshrc

🔨 Usage

To use Gen-Shell, run:

gen-shell 'your task description here'

Example:

❯ gen-shell 'how to check which service is running on port 6463'
Learn More: https://ss64.com/osx/lsof.html
Run Command: `lsof -i :6463`? (Y/n): y
COMMAND     PID   USER   FD   TYPE             DEVICE SIZE/OFF  NODE NAME
Discord   90173   root  56u   IPv4 0x99fa38dd484a062d      0t0  TCP localhost:6463 (LISTEN)

❯ gen-shell 'how to list all running processes'
. . .

⚙️ Advanced Setup

Key Binding

Bind Gen-Shell to a key combination for quick access:

  1. Open your .inputrc file in your home directory (create it if it does not exist).
  2. Add a line to bind a key combination to your command, like so:
"\e[24~":"get-agent\n"
  1. Apply the changes by either restarting your terminal or running bind -f ~/.inputrc.

🤝 Contributing

Contributions are welcome! Please see our contribution guidelines for more details.

📜 License

Gen-Shell is released under the MIT License. See LICENSE for details.

💡 Inspiration

This project is inspired by:


Open to Contributions 🙂.

About

Generative-AI based CLI Assistant Tool

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages