Zsh Ai Cmd banner
kylesnowschwartz kylesnowschwartz

Zsh Ai Cmd

AI community

Description

Zsh plugin: natural language to shell commands with AI

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

zsh-ai-cmd

Natural language to shell commands with ghost text preview.

![Demo](assets/preview.gif)

Install

Requires `curl`, `jq`, and an API key for your chosen provider (or a Claude subscription for the `claude-code` provider).

# Clone
git clone https://github.com/kylesnowschwartz/zsh-ai-cmd ~/.zsh-ai-cmd

# Add to .zshrc
source ~/.zsh-ai-cmd/zsh-ai-cmd.plugin.zsh

# Choose your provider (default: anthropic)
export ZSH_AI_CMD_PROVIDER='anthropic'  # or: openai, gemini, deepseek, ollama, copilot, claude-code

# Set API key for your chosen provider
export ANTHROPIC_API_KEY='sk-ant-...'
export OPENAI_API_KEY='sk-...'
export GEMINI_API_KEY='...'
export DEEPSEEK_API_KEY='sk-...'
# Ollama and Copilot need no key (local services)
# Claude Code uses your existing Claude subscription (requires: npm install -g @anthropic-ai/claude-code && claude login)

# Or use macOS Keychain
security add-generic-password -s 'anthropic-api-key' -a "$USER" -w 'sk-ant-...'

Usage

  1. Type a natural language description
  2. Press Ctrl+Z to request a suggestion
  3. Ghost text appears showing the command: find large files → find . -size +100M
  4. Press Tab or to accept, or keep typing to dismiss

When the model sees more than one reasonable approach, the ghost text shows a cycle counter (`⟲ 1/3`) — press `Ctrl+Z` again to cycle through the alternatives, then `Tab` to accept the one showing.

Destructive suggestions (`rm`, `kill`, `sed -i`, history rewrites, …) are tinted red and marked with `⚠` so you notice before accepting. Providers without structured output (`copilot`, `claude-code`) return a single suggestion and can't flag destructive commands.

Configuration

ZSH_AI_CMD_PROVIDER='anthropic'              # Provider: anthropic, openai, gemini, deepseek, ollama, copilot, claude-code
ZSH_AI_CMD_KEY='^z'                          # Trigger key (default: Ctrl+Z)
ZSH_AI_CMD_HIGHLIGHT='fg=8'                  # Ghost text style (zsh region_highlight format)
ZS