Tiny shell helper that lets you draft, tweak, and run AI-generated commands straight from Bash or Zsh.
It exposes two public functions:
• ai – talks to the OpenAI Chat Completions API
• aio – talks to a local Ollama daemon
- Save the script or clone this repo somewhere.
- In ~/.bashrc or ~/.zshrc add
source /path/to/ai-completion.sh - For
aiexportOPENAI_API_KEY=<your-key>.
Describe the task in plain English:
➜ ai organize all photos in this directory into subfolders using the iso date of the image capture time
$ exiftool '-Directory<DateTimeOriginal' -d '%Y-%m-%d' .
The suggestion appears inline on your prompt. Edit if necessary, press ↵, and it executes.
Anything you pipe into the function is forwarded to the model as extra context, e.g.
➜ git diff --staged | ai write a commit message
$ git commit -am "Refactor payload construction using jq for better JSON handling"Save a buck using local ollama for the easy stuff
➜ aio list stopped docker containers
Using gemma3:4b on http://localhost:11434...
$ docker ps -a --filter status=exitedRequired for ai:
- OPENAI_API_KEY – your OpenAI key
Optional (defaults):
- OPENAI_MODEL (gpt-5-chat-latest)
- OPENAI_TEMP (0.3)
- OLLAMA_MODEL (gemma3:4b)
- OLLAMA_TEMP (0.3)
- OLLAMA_HOST (http://localhost:11434)
Dependencies: curl, jq, and – for aio – a running Ollama daemon somewhere.