zsh-claude
October 2, 2025 ยท View on GitHub
๐ค AI-powered command suggestions and explanations for Zsh using Claude AI. Get intelligent shell command help with simple keybindings.
Transform natural language into executable shell commands, or get detailed explanations of complex commands - all directly in your terminal with Claude AI integration.
โจ Features
- ๐ง Smart Suggestions: Type natural language, get executable commands
- ๐ Command Explanations: Understand what complex commands do
- โก Interactive: Simple keybindings for instant access
- ๐ Standalone: No GitHub CLI dependencies required
- ๐ฏ Multiple AI Models: Choose from Claude 3.5 Haiku to Opus 4.1
- ๐ง Easy Setup: One-command configuration
- ๐ฆ Plugin Manager Support: Works with oh-my-zsh, zinit, antigen, zplug
๐ Quick Start
Prerequisites
- Claude API Key: Get one from console.anthropic.com/settings/keys
- curl: For API requests (usually pre-installed)
- jq: For JSON parsing
# macOS brew install jq # Ubuntu/Debian sudo apt install jq # CentOS/RHEL sudo yum install jq
๐ฆ Installation
Method 1: Oh My Zsh (Recommended)
# Clone the plugin
git clone https://github.com/HundredAcreStudio/zsh-claude ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-claude
# Add to your ~/.zshrc plugins list
plugins=(... zsh-claude)
# Reload your shell
source ~/.zshrc
Method 2: Zinit
# Add to ~/.zshrc
zinit load HundredAcreStudio/zsh-claude
# Reload shell
source ~/.zshrc
Method 3: Manual Installation
# Clone the repository
git clone https://github.com/HundredAcreStudio/zsh-claude ~/.zsh-claude
# Add to ~/.zshrc
echo 'source ~/.zsh-claude/zsh-claude.plugin.zsh' >> ~/.zshrc
# Reload shell
source ~/.zshrc
Other Plugin Managers
Click to expand
Antigen:
antigen bundle HundredAcreStudio/zsh-claude
Zplug:
zplug "HundredAcreStudio/zsh-claude"
โ๏ธ Configuration
After installation, run the setup command:
claude-setup
This interactive setup will:
- Prompt for your Claude API key
- Optional: Configure LiteLLM proxy support
- Let you choose your preferred AI model
- Save configuration securely to
~/.config/zsh-claude/config
Available Models:
- Claude 3.5 Haiku (fast, cost-effective) - Recommended
- Claude 3.7 Sonnet (balanced performance)
- Claude Sonnet 4 (high performance, higher cost)
- Claude Sonnet 4.5 (latest model)
- Claude Opus 4.1 (premium, highest cost)
๐ฏ Usage
Keybindings
| Platform | Suggest Command | Explain Command |
|---|---|---|
| macOS | Option + \ (ยซ) | Option + Shift + \ (ยป) |
| Linux/Windows | Alt + \ | Alt + Shift + \ |
macOS Note: The actual characters produced are
ยซfor suggestions andยปfor explanations
๐ก Command Suggestions
Transform natural language into executable commands:
-
Type your request:
find all python files modified in the last week -
Press the suggestion key (Option+\ on macOS, Alt+\ on Linux/Windows)
-
Command appears:
find . -name "*.py" -mtime -7
More Examples:
# What you type โ What you get
compress all jpg files โ tar -czf images.tar.gz *.jpg
delete all node_modules โ find . -name "node_modules" -type d -exec rm -rf {} +
show disk usage by directory โ du -sh */ | sort -hr
๐ Command Explanations
Understand complex commands instantly:
-
Type or paste a command:
find . -type f -name "*.log" -exec grep -l "ERROR" {} \; -
Press the explanation key (Option+Shift+\ on macOS, Alt+Shift+\ on Linux/Windows)
-
Get detailed breakdown:
Explanation: This command searches for all files with .log extension and finds those containing "ERROR": - find . -type f: searches for files starting from current directory - -name "*.log": matches files ending with .log - -exec grep -l "ERROR" {} \;: runs grep on each file, showing only filenames that contain "ERROR"
๐ง Manual Commands
Use directly from command line:
# Generate suggestions
claude-suggest "compress all jpg files"
# Explain commands
claude-explain "tar -czf archive.tar.gz *.jpg"
# Reconfigure settings
claude-setup
๐จ Customization
Custom Keybindings
The plugin includes default keybindings, but you can customize them in your ~/.zshrc:
# Default keybindings (automatically set by plugin)
bindkey 'ยป' zsh_claude_explain # Option+Shift+\ on macOS
bindkey 'ยซ' zsh_claude_suggest # Option+\ on macOS
# Custom alternatives
bindkey "^[s" zsh_claude_suggest # Alt+s
bindkey "^[e" zsh_claude_explain # Alt+e
bindkey "^@" zsh_claude_suggest # Ctrl+space
macOS Users: The actual characters
ยซandยปare produced by Option+\ and Option+Shift+\ respectively
Available Widgets
zsh_claude_suggest: Generate command suggestionszsh_claude_explain: Explain current command
Configuration File
Advanced users can edit ~/.config/zsh-claude/config:
ZSH_CLAUDE_API_KEY="your-api-key"
ZSH_CLAUDE_MODEL="claude-3-5-haiku-20241022"
ZSH_CLAUDE_API_URL="https://api.anthropic.com/v1/messages"
ZSH_CLAUDE_MAX_TOKENS="1000"
ZSH_CLAUDE_USE_LITELLM="false"
LiteLLM Proxy Support
zsh-claude supports LiteLLM proxy for using alternative LLM providers or custom endpoints:
# Run claude-setup and select LiteLLM proxy option
claude-setup
# Or manually configure in ~/.config/zsh-claude/config:
ZSH_CLAUDE_USE_LITELLM="true"
ZSH_CLAUDE_API_URL="http://localhost:4000/v1/messages"
ZSH_CLAUDE_API_KEY="your-litellm-key"
When LiteLLM mode is enabled, the plugin automatically uses OpenAI-compatible authentication (Authorization: Bearer) instead of Anthropic's native format.
Environment Variables
# Show loading messages even with Powerlevel10k instant prompt
export ZSH_CLAUDE_VERBOSE=1
# Add to ~/.zshrc before loading the plugin
๐ง Troubleshooting
Installation Issues
Powerlevel10k instant prompt warning
Problem: Warning about console output during zsh initialization
Solution: This is normal behavior. The plugin automatically suppresses loading messages when Powerlevel10k instant prompt is detected.
To see loading messages anyway:
# Add to ~/.zshrc before loading the plugin
export ZSH_CLAUDE_VERBOSE=1
Or suppress the warning by adding to ~/.zshrc:
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
Missing dependencies
Problem: "Missing required dependencies" error
Solution: Install missing tools:
# macOS
brew install curl jq
# Ubuntu/Debian
sudo apt install curl jq
# CentOS/RHEL
sudo yum install curl jq
API key issues
Problem: "No API key found" error
Solution: Run setup:
claude-setup
Problem: "API Error: invalid api key"
Solution:
- Get a valid API key from console.anthropic.com/settings/keys
- Run
claude-setupto update your key
Usage Issues
Keybindings not working
Problem: Keys don't trigger suggestions
Solutions:
- Check terminal compatibility
- Try custom keybindings (see Customization section)
- Test with manual commands:
claude-suggest "test"
No suggestions/explanations
Problem: Commands return no results
Checklist:
- โ Internet connection working
- โ
API key is valid (
claude-setup) - โ API credits available
- โ Model name is correct
- โ
Test with:
claude-suggest "list files"
Performance issues
Problem: Slow responses
Solutions:
- Switch to faster model (Claude 3.5 Haiku)
- Check internet connection
- Reduce
ZSH_CLAUDE_MAX_TOKENSin config
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Inspiration
This plugin is inspired by:
- zsh-github-copilot by loiccoyle
- GitHub Copilot CLI
๐ Changelog
v1.0.0
- โจ Standalone Claude AI integration
- ๐ Command suggestion functionality
- ๐ Command explanation functionality
- ๐ฆ Support for multiple plugin managers
- โจ๏ธ Cross-platform keybindings
- ๐ Secure API key management
- ๐ฏ Multiple AI model support