Leverage AI to generate shell commands from plain English.
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.
- 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.
- Python 3.6+
- OpenAI API key
-
Clone the repository
git clone https://github.com/yourusername/gen-shell.git cd gen-shell -
Setup virtual environment (Optional)
python -m venv env source env/bin/activate # Unix/macOS env\Scripts\activate # Windows
-
Install Gen-Shell
pip install -e . -
Environment Configuration
Set your OpenAI API key in your environment:
export OPENAI_API_KEY="Your_OpenAI_API_Key"
-
[Optional] Setup an Alias
Setup gen-sell alias
gsin 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
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'
. . .Bind Gen-Shell to a key combination for quick access:
- Open your
.inputrcfile in your home directory (create it if it does not exist). - Add a line to bind a key combination to your command, like so:
"\e[24~":"get-agent\n"- Apply the changes by either restarting your terminal or running
bind -f ~/.inputrc.
Contributions are welcome! Please see our contribution guidelines for more details.
Gen-Shell is released under the MIT License. See LICENSE for details.
This project is inspired by:
Open to Contributions 🙂.
