Introducing bashGPT
: Convert Plain English to Bash Commands with AI
Do you often forget the right bash commands and wish you could just type what you want to do in plain English? Meet bashGPT
—a handy command-line tool that uses OpenAI's GPT-3.5-turbo to turn your natural language instructions into working bash commands.
🌟 What is bashGPT
?
bashGPT
is a script that takes plain English descriptions of what you want to do and converts them into bash commands that you can execute directly from your terminal. It's particularly handy for those who are new to the command line or just want a more intuitive way to interact with their system.
🚀 How Does It Work?
The tool works by sending your plain English request to OpenAI's GPT-3.5-turbo model. The AI processes your input, translates it into a bash command, and then returns the result. But that's not all—before executing the command, bashGPT
ensures that it's syntactically valid and asks for your confirmation. If the command can’t be converted into a valid bash command, the tool will return null
and exit gracefully.
🛠️ Getting Started
To start using bashGPT
, you'll need to clone the repository, set up your OpenAI API key, and make the script executable. Here’s a quick guide:
-
Clone the Repo:
git clone https://github.com/madhunimmo/bashGPT.git cd bashGPT
-
Set Your OpenAI API Key:
export OPENAI_API_KEY="your-openai-api-key"
-
Make the Script Executable:
chmod +x bashGPT.sh
🔥 Example Usage
You can either pass your command as an argument:
./bashGPT.sh "list all files in the current directory"
Or run it interactively:
./bashGPT.sh
Please enter a command in plain English:
> list all files in the current directory
bashGPT
will generate the bash command ls
, ask you to confirm, and then execute it.
⚠️ Handling Invalid Commands
If your input can’t be translated into a valid bash command, it’ll return an error message like this:
Error: No valid bash command was generated.
This ensures that you’re always in control and only executing what’s actually possible in bash.
🤝 Test & Contribute
Try out bashGPT
and let me know how it works for you! Bug reports, feature suggestions, and code contributions are welcome on GitHub. Even small improvements can make a big difference, so don't hesitate to jump in and help out. Thank you for your support!