ask
is a command-line tool that interacts with OpenAI's GPT-3.5-turbo model to provide UNIX, Mac terminal and Powershell commands based on user prompts. This tool is designed to be easily configurable and accessible from anywhere in your terminal.
- Sends custom prompts to OpenAI and retrieves terminal commands.
- Configurable API key storage.
- Falls back to using
awk
for JSON parsing ifjq
fails or is not available. - Debugging information included to help identify issues.
-
curl
: Command-line tool for transferring data with URLs. -
jq
(optional): Command-line JSON processor. Install using Homebrew:brew install jq
- Powershell 7 is the minimum required version
-
Clone the repository:
git clone https://github.com/yourusername/ask.git cd ask
-
Make the script executable:
chmod +x ask
-
Move the script to a directory in your PATH:
sudo mv ask /usr/local/bin/ask
-
Ensure the directory is in your PATH:
Add the following line to your
~/.zshrc
(or~/.bashrc
for bash users):export PATH=$HOME/bin:$PATH
Reload your profile configuration:
source ~/.zshrc
Before using ask
, you need to configure your OpenAI API key.
-
Run the configure command:
ask --configure
-
Enter your OpenAI API key when prompted. The API key will be saved in
~/.openai_config
.
To use the ask
tool, simply provide a prompt describing what you want to achieve. For example:
ask \"I want to move all my git changes in the current branch to main\"
git checkout main && git merge --strategy=ours <branch-name>
The script includes debugging information that can help identify issues during the execution. It prints out the raw JSON response from the API, the extracted content, and the final cleaned command.
If jq
fails or is not installed, the script falls back to using awk
for JSON parsing.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
This project is licensed under the MIT License.