Chat with AI directly from your shell. This is a simple tool I created for my own use.
pip install rich
sudo cp ai.py /usr/bin/ai
sudo chmod +x /usr/bin/ai
Create or edit the ~/.shell_ai_config
file with your API token and URL:
{
"api_url": "https://api.openai.com/v1/chat/completions",
"api_token": "YOUR-TOKEN-HERE"
}
To interact with the AI, simply type:
ai Can you show me some examples of markdown
If your prompt includes special characters, enclose it in quotes:
ai "Can you show me some examples of markdown?"
You can add output of a shell command to context.
ai exec [shell command]
For example, you can include a txt file in the context by ai exec cat text.txt
:
To reset the AI's context, use the following command:
ai reset