Skip to content

briques/ohmyai-zsh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

ohmyai

AI-powered command suggestions for Zsh. Type what you want to do, press the hotkey, and get shell command suggestions from OpenAI.

Requirements

  • 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)

Install dependencies

python3 setup.py

This installs jq, curl, and fzf via Homebrew (macOS) or apt/dnf (Linux). The plugin will warn on load if any are missing.

Installation

Oh My Zsh

  1. Clone into your custom plugins directory:
git clone https://github.com/briques/ohmyai ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/ohmyai
  1. Add the plugin to your .zshrc:
plugins=(... ohmyai)
  1. Set your OpenAI API key:
export OHMYAI_OPENAI_API_KEY="sk-..."
  1. (Optional) Install fzf for a nicer selection UI:
brew install fzf   # macOS

Usage

  1. Type what you want to do (e.g. list all json files in this directory or git status)
  2. Press Ctrl+o (or your configured hotkey)
  3. Select a suggestion (fzf menu or numbered list)
  4. The command is inserted into your buffer

Configuration

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)

Example

export OHMYAI_OPENAI_API_KEY="sk-..."
OHMYAI_MODEL='gpt-4o'
OHMYAI_N_SUGGESTIONS=8
OHMYAI_HOTKEY='^o'

Security

  • 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.

License

MIT

About

AI-powered shell command suggestions for Zsh. Type what you want to do, press Ctrl+o, get suggestions from OpenAI. Oh My Zsh plugin with fzf selection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors