AI-powered command suggestions for Zsh. Type what you want to do, press the hotkey, and get shell command suggestions from OpenAI.
- Oh My Zsh
- curl
- jq or Python 3 (fallback when API returns malformed JSON)
- OpenAI API key
- fzf (optional, for fuzzy selection UI – uses first suggestion if not installed)
python3 setup.pyThis installs jq, curl, and fzf via Homebrew (macOS) or apt/dnf (Linux). The plugin will warn on load if any are missing.
- Clone into your custom plugins directory:
git clone https://github.com/briques/ohmyai ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyai- Add the plugin to your
.zshrc:
plugins=(... ohmyai)- Set your OpenAI API key:
export OHMYAI_OPENAI_API_KEY="sk-..."- (Optional) Install fzf for a nicer selection UI:
brew install fzf # macOS- Type what you want to do (e.g.
list all json files in this directoryorgit status) - Press Ctrl+o (or your configured hotkey)
- Select a suggestion (fzf menu or numbered list)
- The command is inserted into your buffer
Set these in your .zshrc before Oh My Zsh loads:
| Variable | Default | Description |
|---|---|---|
OHMYAI_OPENAI_API_KEY |
(required) | Your OpenAI API key |
OHMYAI_HOTKEY |
^o (Ctrl+o) |
Keybinding to trigger suggestions |
OHMYAI_MODEL |
gpt-4o-mini |
OpenAI model (e.g. gpt-4o for better quality) |
OHMYAI_N_SUGGESTIONS |
5 |
Max number of suggestions to show |
OHMYAI_MAX_TOKENS |
200 |
Max tokens for API response (lower = cheaper, ~50 tokens per command) |
OHMYAI_FZF_OPTS |
(purple theme) | fzf options for selection UI (e.g. --border=sharp) |
export OHMYAI_OPENAI_API_KEY="sk-..."
OHMYAI_MODEL='gpt-4o'
OHMYAI_N_SUGGESTIONS=8
OHMYAI_HOTKEY='^o'- Never commit your API key. Use environment variables or a separate config file (e.g.
~/.zshrc.local) that you don't share. - The plugin sends your current input and recent command history to OpenAI. History is sanitized to exclude
OHMYAI_OPENAI_API_KEY=lines. - If your API key was exposed (e.g. in debug output or shared config), rotate it immediately at platform.openai.com.
MIT