zsh-claude-code
Health Gecti
- License — License: MIT
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 12 GitHub stars
Code Gecti
- Code scan — Scanned 12 files during light audit, no dangerous patterns found
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Claude in your zsh prompt: ask, explain, and Ctrl+X / Alt+E widgets that turn natural language into shell commands. Wraps the Claude Code CLI, no extra deps.
zsh-claude-code
Claude-powered helpers for your zsh prompt. Ask questions, explain commands, and turn natural language into shell commands - without leaving the terminal.
All four features wrap the claude CLI (Claude Code) in --print mode, so if you're already logged in with claude login there's nothing else to set up.
- Ctrl+X - describe a command in plain English, press to rewrite the line into shell.
- Alt+E - type or paste a command, press to print an explanation above it.
Features
| What | Trigger | Default model | |
|---|---|---|---|
| Ask | Terse answer to any dev/terminal question | ask <question> |
sonnet |
| Explain | Summarize a command in natural, concise English | explain <command> |
sonnet |
| Suggest widget | Rewrite the current line (natural language) → one shell command, in place | Ctrl+X | sonnet |
| Explain widget | Explain the command currently at the prompt, above it (command stays intact) | Alt+E | sonnet |
Requirements
zsh5.0+claudeCLI installed and authenticated (eitherclaude loginorANTHROPIC_API_KEYin the environment)- No other runtime dependencies
Installation
zinit (recommended)
Requires zinit. Add to your ~/.zshrc after zinit is initialized:
zinit light matheus-poli/zsh-claude-code
Restart your shell or source ~/.zshrc.
oh-my-zsh
If you use oh-my-zsh, clone into the custom plugins dir:
git clone https://github.com/matheus-poli/zsh-claude-code \
"${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-claude-code"
Add zsh-claude-code to your plugins=(...) in ~/.zshrc, then restart your shell or source ~/.zshrc.
Manual
git clone https://github.com/matheus-poli/zsh-claude-code ~/.zsh-claude-code
echo 'source ~/.zsh-claude-code/zsh-claude-code.plugin.zsh' >> ~/.zshrc
Usage
ask
ask how do I list files modified in the last 24 hours
ask "what's the difference between \$* and \$@ in zsh?"
Prints a terse answer. If the answer is a command, it shows the command first in a fenced block, then at most one short line of context.
explain
explain 'find . -type f -exec md5sum {} + | sort | uniq -w32 -dD'
Prints one overview line + a short bullet per flag/argument.
Wrap the command in single quotes whenever it contains shell metacharacters (|, >, <, &, ;, $, backticks). noglob only suppresses glob expansion (*, ?, [...]); it doesn't stop zsh from parsing pipes or redirects, so an unquoted pipeline would actually run.
Suggest widget (Ctrl+X)
Type a natural-language request, then press Ctrl+X:
find all js files larger than 100kb modified in the last week
becomes:
find . -name "*.js" -size +100k -mtime -7
Review the command, press Enter to run (or edit first).
Explain widget (Alt+E)
Type or paste a command at the prompt, then press Alt+E. The explanation prints above the prompt; your command stays intact so you can still edit or run it.
Configuration
Set any of these in ~/.zshrc before the plugin loads (especially keybinds - they're resolved at source time).
| Variable | Default | Description |
|---|---|---|
ZSH_CLAUDE_ASK_MODEL |
sonnet |
Model for ask |
ZSH_CLAUDE_EXPLAIN_MODEL |
sonnet |
Model for explain + explain widget |
ZSH_CLAUDE_SUGGEST_MODEL |
sonnet |
Model for the suggest widget |
ZSH_CLAUDE_SUGGEST_KEY |
^X |
Keybind for the suggest widget |
ZSH_CLAUDE_EXPLAIN_KEY |
^[e |
Keybind for the explain widget (^[e = Alt+E) |
ZSH_CLAUDE_ASK_SYSTEM_PROMPT |
(built-in) | Full override of the ask system prompt |
ZSH_CLAUDE_EXPLAIN_SYSTEM_PROMPT |
(built-in) | Full override of the explain system prompt |
ZSH_CLAUDE_SUGGEST_SYSTEM_PROMPT |
(built-in) | Full override of the suggest system prompt |
ZSH_CLAUDE_EXTRA_FLAGS |
(empty) | Extra flags appended to every claude -p call (advanced) |
Example: change keybind and use a stronger ask model
# ~/.zshrc - BEFORE the plugins=(...) line
export ZSH_CLAUDE_SUGGEST_KEY='^G' # Ctrl+G instead of Ctrl+X
export ZSH_CLAUDE_ASK_MODEL='opus' # stronger model for ask, slower
Troubleshooting
- "command not found: claude" - the plugin no-ops gracefully when
claudeisn't on$PATH. Install Claude Code and runclaude login. - Widget doesn't fire - another plugin may have rebound
^X. Try settingZSH_CLAUDE_SUGGEST_KEYto something else, or usebindkey | grep claudeto confirm the binding. - Output has stray backticks / code fences - please open an issue with the input that produced it. The suggest widget already scrubs fences defensively, but prompts evolve.
Contributing
Contributions welcome - PRs, bug reports, feature ideas. Quick start:
git clone https://github.com/matheus-poli/zsh-claude-code
cd zsh-claude-code
mise run setup # pinned tools, commitlint deps, git hooks — one command
mise run check # lint + unit tests + smoke
If anything feels off, mise run doctor walks through the environment and tells you exactly what's missing.
First time using mise? Install it once globally (it pins per-project versions of node, bats, lefthook), then the commands above work from any fresh clone.
Available tasks:
| Task | What it does |
|---|---|
mise run setup |
Pinned tools → commitlint deps → git hooks |
mise run doctor |
Diagnose tools, hooks, and the claude CLI |
mise run lint |
zsh -n syntax check on plugin + script files |
mise run test |
bats test/ |
mise run smoke |
End-to-end ask call (needs an authenticated claude CLI) |
mise run check |
Lint + tests + smoke — run this before sending a PR |
Commits follow Conventional Commits (feat:, fix:, docs:, chore:, …) - enforced by commitlint via a lefthook commit-msg hook. This drives automated semver releases.
Manual test checklist before sending a PR that touches the plugin code:
askandexplainwith?,!,*, and quoted strings- Ctrl+X with a clear request and an ambiguous one
- Alt+E on a typed command - original command must stay intact
- All four features with
claudelogged out → helpful error, not a crash - Custom keybinds set before plugin load
See CLAUDE.md for design notes and the full rationale behind each decision.
Contributors
Matheus Poli 💻 📖 🚧 🎨 🤔 |
This project follows the all-contributors specification. Contributions of any kind welcome!
To add yourself after a merged PR, comment on the PR:
@all-contributors please add @your-username for code, doc
License
MIT © Matheus Poli
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi