A lightweight Zsh plugin that predict your next command using llm. You can also ask to create a command.
Make sure you have cURL and jq installed.
If you would like to have markdown rendering with option -m, glow is required (Recommend).
Acquire your private api-key from OpenAI.
It's simple and easy to use. Just run the following command in your terminal:
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/Gamma-Software/zsh-copilot/refs/heads/master/install.sh)"- Clone this repository into
$ZSH_CUSTOM/plugins(by default~/.oh-my-zsh/plugins)
git clone https://github.com/Gamma-Software/zsh-copilot ${ZSH_CUSTOM:-~/.oh-my-zsh}/plugins/zsh-copilot- Add the plugin to the list of plugins for Oh My Zsh to load (inside
~/.zshrc):
plugins=(
# other plugins...
zsh-copilot
)- Add the following to your
$ZSH_CUSTOM/plugins/zsh-copilot/.envfile:
ZSH_COPILOT_API_KEY="<Your API key here>"- Restart your terminal or run:
source ~/.zshrcRun the command:
zsh-copilot uninstallFill your OpenAI api key as ZSH_ASK_API_KEY (see INSTALL.md for detail information), then just run
zsh-copilot who are you
To fix previous command error.
zsh-copilot fix
Note: You can also use zcf instead of zsh-copilot fix.
To ask to create a command.
zsh-copilot ask <command to generate>
Note: You can also use zca instead of zsh-copilot ask.
For instance, you can ask to create a command to search for a file in the current directory.
zsh-copilot ask search for the file "test.txt" in the current directory
Use -c for dialogue format communication.
zsh-copilot -c chat with me
Use -m for markdown rendering (glow required)
zsh-copilot -m how to code quick sort in python
Use -s for streaming display (doesn't work with -m yet)
zsh-copilot -s write a poem for me
Use -i to inherits history from last chat (which is recorded in ZSH_COPILOT_HISTORY).
zsh-copilot -i tell me more about it
Use -h for more information.
zsh-copilot -h
This plugin provides two powerful command-line features:
-
Command Prediction (Option+p or Ctrl+x p)
- Analyzes your recent command history
- Suggests the next likely command based on your patterns
- Press Option+p (Mac) or Ctrl+x p to see the prediction
- The predicted command appears in your command line ready to execute
-
Command Generation (Option+a or Ctrl+x a)
- Type what you want to do in plain English
- Press Option+a (Mac) or Ctrl+x a to generate the command
- Example: Type "find all PDF files modified today" and press Option+a
- The generated command appears in your command line ready to execute
-
Error Fixing (Option+f or Ctrl+x f)
- Automatically captures the last failed command and its error
- Generates a corrected version of the command
- Press Option+f (Mac) or Ctrl+x f to see the fixed command
- The corrected command appears in your command line ready to execute
Both features:
- Place commands directly in your command line
- Allow you to edit before executing
- Can be cancelled with Ctrl+C
- Support full command-line editing
Have fun!
You can use zsh-copilot as zc. For fixing errors, you can use zcf. For asking to create a command, you can use zca.
This project is licensed under MIT license. For the full text of the license, see the LICENSE file.