A Zsh plugin that brings the power of Large Language Models (LLMs) directly to your terminal. It helps you understand complex shell commands and generates commands from natural language descriptions.
- Explain Command (
Ctrl+Xe): Get a clear, plain-English explanation of the command currently in your buffer. - Suggest Command (
Ctrl+Xs): Type what you want to do in natural language, and let the LLM replace it with the correct shell command. - Multi-Provider Support: Works with
copilot,gemini,claude, andcodexCLI tools. - Non-Blocking UI: Features a visual loading indicator ("Thinking...", "Suggesting...") that doesn't freeze your shell, powered by
zsh/zselect. - Persistent Output: Explanations and errors are printed above your prompt so they don't vanish when you continue typing.
IMPORTANT: This plugin is a wrapper. It does not include an LLM engine itself. You must have one of the following CLI tools installed, authenticated, and available in your $PATH for this plugin to function:
- Copilot CLI:
gh copilot(or standalonecopilot) - Gemini CLI:
gemini - Claude Code:
claude - Codex CLI:
codex
-
Clone this repository into your custom plugins directory:
git clone https://github.com/yourusername/zsh-llm-assist.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-llm-assist -
Add the plugin to the list of plugins in your
.zshrc:plugins=(... zsh-llm-assist)
-
Restart your terminal or run
source ~/.zshrc.
- Clone the repository.
- Source the script in your
.zshrc:source /path/to/zsh-llm-assist/zsh-llm-assist.plugin.zsh
Type a command (or part of one) into your terminal, but don't press Enter.
Example buffer:
tar -czf archive.tar.gz /path/to/folderPress Ctrl+X then e (default).
The plugin will print an explanation above your prompt.
Type what you want to do in plain English.
Example buffer:
find all python files modified yesterday and delete them
Press Ctrl+X then s (default).
The text will be replaced by the actual shell command (e.g., find . -name "*.py" -mtime 1 -delete).
You can configure the plugin by setting variables in your .zshrc.
Choose which CLI tool to use. Default is gemini.
export ZSH_LLM_CLI_TOOL="gemini" # Options: copilot, gemini, claude, codexThe plugin binds llm_explain and llm_suggest to Ctrl+X e and Ctrl+X s by default. You can override these in your .zshrc after the plugin is loaded:
# Use Ctrl+G for suggestions and Ctrl+E for explanations
bindkey '^G' llm_suggest
bindkey '^E' llm_explainOverride the default models for specific tools:
export ZSH_LLM_GEMINI_MODEL="gemini-1.5-pro"
export ZSH_LLM_CLAUDE_MODEL="claude-3-opus-20240229"
export ZSH_LLM_CODEX_MODEL="gpt-4o"If things aren't working, enable debug mode to see the exact command being executed and any error messages.
export ZSH_LLM_CLI_DEBUG=trueIf your CLI tool is not in your $PATH or has a different name, you can specify the full path:
export ZSH_LLM_BIN_PATH="/opt/bin/custom-gemini-cli"Note: If unset, it defaults to the value of ZSH_LLM_CLI_TOOL.
MIT