Home

Awesome

ZSH AI Commands

zsh-ai-commands-demo

This plugin works by asking GPT (gpt-4o) for terminal commands that achieve the described target action.

To use it just type what you want to do (e.g. list all files in this directory) and hit the configured hotkey (default: Ctrl+o). When GPT responds with its suggestions just select the one from the list you want to use.

Requirements

Installation

oh-my-zsh

Clone the repository to you oh-my-zsh custom plugins folder:

git clone https://github.com/muePatrick/zsh-ai-commands ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-ai-commands

Enable it in your .zshrc by adding it to your plugin list:

plugins=(... zsh-ai-commands ...)

Set the API key in your by setting:

ZSH_AI_COMMANDS_OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Replace the placeholder with your own key. The config can be set e.g in your .zshrc in this case be careful to not leak the key should you be sharing your config files.

Configuration Variables

VariableDefaultDescription
ZSH_AI_COMMANDS_OPENAI_API_KEY-/- (not set)OpenAI API key
ZSH_AI_COMMANDS_HOTKEY'^o' (Ctrl+o)Hotkey to trigger the request
ZSH_AI_COMMANDS_LLM_NAMEgpt-4oLLM name
ZSH_AI_COMMANDS_N_GENERATIONS5Number of completions to ask for
ZSH_AI_COMMANDS_EXPLAINERtrueIf true, GPT will comment the command
ZSH_AI_COMMANDS_HISTORYfalseIf true, save the natural language prompt to the shell history (and atuin if installed)

Known Bugs