Plugins give fish-like suggestions and highlighting, but each one costs startup time.
A zsh plugin is just a script you source from .zshrc, sometimes adding a directory to fpath for completions. Two are near-universal:
- zsh-autosuggestions: shows a grey suggestion from history as you type; Right arrow or End accepts it.
- zsh-syntax-highlighting: colours the command line, red for unknown commands. Source it last, after other plugins and key bindings.
You can manage plugins three ways: clone repositories and source them yourself, use a lightweight plugin manager (antidote, zinit, zap), or use a framework. Oh My Zsh is the best-known framework: it bundles hundreds of plugins (plugins=(git docker kubectl)) and themes. It is convenient but loads a lot; measure with time zsh -i -c exit and keep the list short.
Beyond normal aliases, zsh has two extra kinds:
- global aliases (
alias -g G='| grep -i') expand anywhere on the line, not only in command position, - suffix aliases (
alias -s md=less) open a file by typing its name:README.mdrunsless README.md.
Use global aliases sparingly: they expand even inside arguments where you did not expect them. alias with no arguments lists everything currently defined, which helps when a framework surprises you.
Example
# Manual setup (no framework): clone once, then source in ~/.zshrc
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.zsh/zsh-syntax-highlighting
# ~/.zshrc
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
alias gs='git status' # normal alias: command position only
alias -g G='| grep -i' # global alias: anywhere in the line
alias -s md=less # suffix alias: README.md -> less README.md
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh # last
# At the prompt:
ps aux G zsh # runs: ps aux | grep -i zsh
time zsh -i -c exit # how long your config takes to load
# With Oh My Zsh instead, in ~/.zshrc: plugins=(git docker kubectl)Remember
- Plugins are sourced scripts; source syntax highlighting last
- alias -g expands anywhere, alias -s opens files by extension
- Measure startup time and keep plugins few
Watch out for
- Loading dozens of Oh My Zsh plugins and then living with a one-second shell startup.