cheat-sheets

antidote

antidote is a fast Zsh plugin manager. It clones plugins from Git, then generates one static file that your ~/.zshrc sources, so start-up stays quick. It can load Oh My Zsh plugins without the full framework.

Project: antidote Documentation: antidote on GitHub

Checked against antidote 2.3.0 using antidote help and its man pages.

Install #

zsh
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote

Then in ~/.zshrc:

zsh
source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh
antidote load

antidote load reads ${ZDOTDIR:-$HOME}/.zsh_plugins.txt, regenerates the static .zsh_plugins.zsh when needed and sources it.

Commands #

COMMANDDESCRIPTION
antidote loadStatically source all bundles from the plugins file
antidote bundle <FILEClone bundles and print the static load script
antidote install OWNER/REPOClone a bundle and add it to the plugins file
antidote updateUpdate antidote and every cloned bundle
antidote purge OWNER/REPORemove one cloned bundle (--all removes every one)
antidote listList cloned bundles (-l detail, -d dirs, -u URLs, -j JSON Lines)
antidote path OWNER/REPOPrint where a bundle is cloned
antidote homePrint the folder bundles are cloned into
antidote initSet up dynamic bundling (see below)
antidote snapshot save / list / restore / remove / homeManage point-in-time snapshots of bundle commits
antidote help [COMMAND]Show the manual
antidote --version, antidote --diagnosticsVersion and diagnostics

The Plugins File #

One bundle per line in ~/.zsh_plugins.txt. # starts a comment. A bundle is OWNER/REPO (GitHub), a full Git URL, or a local file or folder.

text
# plugins
zsh-users/zsh-completions kind:fpath path:src
zsh-users/zsh-autosuggestions
zsh-users/zsh-syntax-highlighting

# Oh My Zsh pieces
getantidote/use-omz
ohmyzsh/ohmyzsh path:lib
ohmyzsh/ohmyzsh path:plugins/git
ohmyzsh/ohmyzsh path:plugins/sudo

# theme
romkatv/powerlevel10k

Load zsh-syntax-highlighting near the end of the file; it must be loaded after other plugins that add widgets.

Annotations #

Written as keyword:value after the bundle.

ANNOTATIONEFFECT
kind:zshSource it as a plugin (the default)
kind:fpathOnly add it to $fpath (completions)
kind:pathAdd it to $PATH
kind:cloneOnly clone it
kind:deferLoad it after the prompt using romkatv/zsh-defer
kind:autoloadAutoload every file in the folder as a function
path:SUBDIRUse a subfolder or file of the repo (e.g. path:plugins/git)
branch:NAMEUse a branch or tag instead of the default branch
pin:SHALock to a full 40-character commit; skipped by antidote update
conditional:FUNCLoad only when the zero-argument function succeeds
pre:FUNC, post:FUNCRun a function before / after the plugin loads
autoload:DIRAlso autoload a functions folder

Directives start a line and affect the lines after them:

text
preset:ohmyzsh/ohmyzsh pin:FULL_40_CHAR_SHA

using:ohmyzsh/ohmyzsh path:plugins
git
sudo
extract

using: lets you list Oh My Zsh plugins as bare names. preset: sets default annotations for a bundle.

Dynamic Bundling #

No separate plugins file: bundles are listed in ~/.zshrc.

zsh
source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh
source <(antidote init)
antidote bundle zsh-users/zsh-autosuggestions
antidote bundle ohmyzsh/ohmyzsh path:plugins/git

Snapshots are only saved automatically after antidote update in static mode.

Customisation #

Set these with zstyle in ~/.zshrc before antidote load:

ZSTYLEEFFECT
zstyle ':antidote:bundle' file PATHUse another plugins file
zstyle ':antidote:static' file PATHUse another static file
zstyle ':antidote:bundle:*' zcompile 'yes'Zsh-compile bundles
zstyle ':antidote:bundle:*' min-age 7Hold bundles back by 7 days from upstream’s newest commit
zstyle ':antidote:snapshot' max 25Keep at most 25 snapshots
ANTIDOTE_HOME=PATHClone bundles somewhere else (default ~/.cache/antidote)

Regenerate Only When the File Changes #

Avoids a rebuild on every shell start:

zsh
zsh_plugins=${ZDOTDIR:-~}/.zsh_plugins
if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then
  antidote bundle <${zsh_plugins}.txt >${zsh_plugins}.zsh
fi
source ${zsh_plugins}.zsh

Troubleshooting #

SYMPTOMFIX
New plugin not loadedThe static file is stale: touch ~/.zsh_plugins.txt or delete ~/.zsh_plugins.zsh, then start a new shell
antidote: command not found~/.zshrc must source antidote.zsh first
A plugin broke after an updateantidote snapshot list, then antidote snapshot restore FILE, or pin: the bundle
Pin or branch inconsistentThe same repo has different pin: / branch: on different lines: use preset: once
OMZ plugin cannot find helpersLoad getantidote/use-omz and ohmyzsh/ohmyzsh path:lib before OMZ plugins

See Also #

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.