Plugins vs Snippets
Summary
Section titled “Summary”Plugins are Git repositories cloned from GitHub (or other hosts); snippets are single files sourced by direct URL or via shorthand aliases. Choosing between them depends on whether the content lives in a full repo or a standalone file.
Details
Section titled “Details”Plugins are loaded with zinit load or zinit light. Zinit clones the repository with git clone and sources the appropriate entry-point file (matching *.plugin.zsh, init.zsh, or *.zsh-theme). Plugins are stored under $ZINIT[PLUGINS_DIR] and can be updated with zinit update.
Snippets are loaded with zinit snippet. Zinit downloads the file and caches it locally under $ZINIT[SNIPPETS_DIR]. Subsequent loads use the cache; pass -f to force a fresh download. Snippets support several URL shorthands:
| Shorthand | Expands to |
|---|---|
OMZ:: | https://github.com/ohmyzsh/ohmyzsh/raw/master/ |
OMZL:: | …/lib/ |
OMZP:: | …/plugins/ |
OMZT:: | …/themes/ |
PZT:: | https://github.com/sorin-ionescu/prezto/tree/master/ |
PZTM:: | …/modules/ |
When a snippet requires multiple files from a subdirectory, add zi ice svn to download the directory via Subversion rather than a single file.
Key behavioural differences:
- Several ices (
depth,from,bpick,ver,proto,cloneopts,pullopts,bindmap,trackbinds,wrap-track) do not work with snippets because there is no Git repo involved. svnandlinkices do not work with plugins.- Snippets are cached; plugins are full clones — snippets are lighter for single-file content from known URLs.
Examples
Section titled “Examples”# Plugin — full Git repo, load with reportingzinit load zdharma-continuum/history-search-multi-word
# Plugin — fast load, no reportingzinit light zsh-users/zsh-autosuggestions
# Snippet — raw URLzinit snippet https://gist.githubusercontent.com/hightemp/5071909/raw/
# Snippet — OMZ shorthandzinit snippet OMZL::git.zshzinit snippet OMZP::gitzinit snippet OMZT::robbyrussell
# Snippet — Prezto shorthandzinit snippet PZTM::environment
# Multi-file snippet (subdirectory via SVN)zi ice svnzi snippet OMZP::gitfast
# Single-file completion snippetzi ice as"completion"zi snippet OMZP::docker/_dockerCaveats / Common Mistakes
Section titled “Caveats / Common Mistakes”- Using
zi snippet OMZP::gitloads a singlegit.plugin.zsh; if the plugin contains multiple files or an_*completion, usesvnoras"completion"as appropriate. - Snippet cache is not automatically invalidated on remote changes; run
zinit update {URL}orzinit update --allto refresh.