Migrating From Zinit

If you are migrating from zinit to antidote, most of your config maps over directly. Zinit configures each plugin with zinit ice modifiers on the line before it loads. Antidote puts the same information on one line per plugin, as annotations in a plugins file.

The short version

Your plugins move into ${ZDOTDIR:-$HOME}/.zsh_plugins.txt, one per line:

# .zsh_plugins.txt
romkatv/powerlevel10k
mattmc3/ez-compinit
zsh-users/zsh-completions kind:fpath path:src
ohmyzsh/ohmyzsh path:lib/git.zsh
ohmyzsh/ohmyzsh path:plugins/git
zsh-users/zsh-autosuggestions
zdharma-continuum/fast-syntax-highlighting kind:defer

And your .zshrc loads them:

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

That plugins file replaces a zinit config like this one:

# .zshrc
source ${XDG_DATA_HOME:-$HOME/.local/share}/zinit/zinit.git/zinit.zsh

zinit ice depth"1"
zinit light romkatv/powerlevel10k

zinit ice blockf
zinit light zsh-users/zsh-completions

zinit snippet OMZL::git.zsh
zinit snippet OMZP::git

zinit light zsh-users/zsh-autosuggestions

zinit ice wait lucid atinit"zicompinit; zicdreplay"
zinit light zdharma-continuum/fast-syntax-highlighting

antidote load clones anything missing and generates a static file of plain source and fpath lines. It only regenerates that file when your plugins file changes, so a normal shell startup is just sourcing it.

If you’d rather keep your plugins in .zshrc the way zinit does, antidote’s dynamic mode works too:

# .zshrc
source ${ZDOTDIR:-$HOME}/.antidote/antidote.zsh
source <(antidote init)
antidote bundle zsh-users/zsh-autosuggestions
antidote bundle zdharma-continuum/fast-syntax-highlighting kind:defer

Converting plugins

Each pair below shows the zinit lines from a .zshrc, then the antidote line that replaces them in .zsh_plugins.txt. An ice with no antidote line next to it just goes away.

Plain plugins

light and load are the same to antidote.

# zinit (.zshrc)
zinit light zsh-users/zsh-autosuggestions
zinit load zdharma-continuum/history-search-multi-word
# antidote (.zsh_plugins.txt)
zsh-users/zsh-autosuggestions
zdharma-continuum/history-search-multi-word

pick, src, and multisrc

pick and src become path:. Each extra file to source, including each file in a multisrc, is its own line with the repo repeated.

# zinit (.zshrc)
zinit ice pick"z.sh"
zinit light rupa/z

zinit ice pick"lib/misc.zsh" src"lib/grep.zsh"
zinit light ohmyzsh/ohmyzsh
# antidote (.zsh_plugins.txt)
rupa/z path:z.sh
ohmyzsh/ohmyzsh path:lib/misc.zsh
ohmyzsh/ohmyzsh path:lib/grep.zsh

as”program”

as"program" (or as"command") becomes kind:path, which puts the plugin directory on your $PATH.

# zinit (.zshrc)
zinit ice as"program" pick"zsh-bench"
zinit light romkatv/zsh-bench
# antidote (.zsh_plugins.txt)
romkatv/zsh-bench kind:path

as”completion” and blockf

A completions plugin loaded with either becomes kind:fpath, which adds the directory to fpath and sources nothing. Use path: to point at the directory the completions live in.

# zinit (.zshrc)
zinit ice blockf
zinit light zsh-users/zsh-completions
# antidote (.zsh_plugins.txt)
zsh-users/zsh-completions kind:fpath path:src

as”null”

as"null" becomes kind:clone, which clones the repo and loads nothing.

# zinit (.zshrc)
zinit ice as"null"
zinit light mbadolato/iTerm2-Color-Schemes
# antidote (.zsh_plugins.txt)
mbadolato/iTerm2-Color-Schemes kind:clone

wait and lucid (turbo mode)

wait becomes kind:defer, which loads the plugin after the prompt with zsh-defer. lucid goes away, since deferred loading is quiet already. There are no wait"2" timers or wait conditions; the defer-options zstyle passes flags to zsh-defer.

# zinit (.zshrc)
zinit ice wait lucid
zinit light olets/zsh-abbr
# antidote (.zsh_plugins.txt)
olets/zsh-abbr kind:defer

atinit and atload

atinit becomes pre: and atload becomes post:. Antidote takes the name of a function instead of a string of code, so move the code into a function in your .zshrc, defined before antidote load.

# zinit (.zshrc)
zinit ice atinit'ZSH_AUTOSUGGEST_STRATEGY=(history completion)'
zinit light zsh-users/zsh-autosuggestions

zinit ice atload'bindkey "^[[A" history-substring-search-up; bindkey "^[[B" history-substring-search-down'
zinit light zsh-users/zsh-history-substring-search
# antidote (.zshrc)
autosuggest_setup() {
  ZSH_AUTOSUGGEST_STRATEGY=(history completion)
}
hss_bindkeys() {
  bindkey "^[[A" history-substring-search-up
  bindkey "^[[B" history-substring-search-down
}
antidote load
# antidote (.zsh_plugins.txt)
zsh-users/zsh-autosuggestions pre:autosuggest_setup
zsh-users/zsh-history-substring-search post:hss_bindkeys

has and if

Both become conditional:, which loads the plugin only when a function returns success.

# zinit (.zshrc)
zinit ice has'fzf'
zinit light Aloxaf/fzf-tab

zinit ice if'[[ $OSTYPE == darwin* ]]'
zinit snippet OMZP::macos
# antidote (.zshrc)
has_fzf() { (( $+commands[fzf] )) }
is_macos() { [[ $OSTYPE == darwin* ]] }
antidote load
# antidote (.zsh_plugins.txt)
Aloxaf/fzf-tab conditional:has_fzf
ohmyzsh/ohmyzsh path:plugins/macos conditional:is_macos

ver

ver with a branch becomes branch:, and with a tag becomes tag:. A tag can also be a range, like tag:^0.7, which follows new releases on antidote update.

# zinit (.zshrc)
zinit ice ver"develop"
zinit light zsh-users/zsh-autosuggestions

zinit ice ver"0.8.0"
zinit light zsh-users/zsh-syntax-highlighting
# antidote (.zsh_plugins.txt)
zsh-users/zsh-autosuggestions branch:develop
zsh-users/zsh-syntax-highlighting tag:0.8.0

depth and compile

Neither has an annotation. Antidote clones shallow and then fetches history in the background, so depth"1" goes away. Compiling is a zstyle set once in your .zshrc.

# zinit (.zshrc)
zinit ice depth"1" compile"*.zsh"
zinit light romkatv/powerlevel10k
# antidote (.zshrc)
zstyle ':antidote:bundle:*' zcompile yes
# optional: never fetch more than the shallow clone
zstyle ':antidote:bundle:romkatv/powerlevel10k' shallow yes
antidote load
# antidote (.zsh_plugins.txt)
romkatv/powerlevel10k

Oh My Zsh and Prezto snippets

Zinit’s OMZ::, OMZL::, OMZT::, OMZP::, and PZTM:: shorthands become path: annotations on the framework repo. The repo is cloned once, however many paths you use from it. Since antidote loads a whole plugin directory, multi-file plugins don’t need zinit’s svn ice.

# zinit (.zshrc)
zinit snippet OMZL::git.zsh
zinit snippet OMZL::clipboard.zsh
zinit snippet OMZP::git
zinit ice svn
zinit snippet OMZP::gitfast
zinit snippet OMZT::robbyrussell.zsh-theme
zinit snippet PZTM::environment
# antidote (.zsh_plugins.txt)
ohmyzsh/ohmyzsh path:lib/git.zsh
ohmyzsh/ohmyzsh path:lib/clipboard.zsh
ohmyzsh/ohmyzsh path:plugins/git
ohmyzsh/ohmyzsh path:plugins/gitfast
ohmyzsh/ohmyzsh path:themes/robbyrussell.zsh-theme
sorin-ionescu/prezto path:modules/environment

With many Oh My Zsh plugins, using: saves repeating the repo, and use-omz sets up what Oh My Zsh plugins expect:

# antidote (.zsh_plugins.txt)
getantidote/use-omz
ohmyzsh/ohmyzsh path:lib

using:ohmyzsh/ohmyzsh path:plugins
git
extract
magic-enter

See Using Zsh Frameworks for more.

Completions

Zinit needs zicompinit and zicdreplay when completions load in turbo mode. Antidote doesn’t track compdef calls, so there is nothing to replay. Run compinit once, or bundle a plugin that does it for you. See Completions.

# zinit (.zshrc)
zinit ice wait lucid blockf
zinit light zsh-users/zsh-completions
zinit ice wait lucid atinit"zicompinit; zicdreplay"
zinit light zdharma-continuum/fast-syntax-highlighting
# antidote (.zsh_plugins.txt)
mattmc3/ez-compinit
zsh-users/zsh-completions kind:fpath path:src
zdharma-continuum/fast-syntax-highlighting kind:defer

Commands

zinit antidote
zinit update, zinit update --all antidote update
zinit self-update antidote update --self
zinit delete owner/repo antidote purge owner/repo
zinit list-plugins, zinit report antidote list
zinit cd owner/repo cd $(antidote path owner/repo)

What doesn’t carry over

Antidote manages zsh plugins from git repos. Zinit also manages software, and that part has no antidote equivalent:

  • from"gh-r" binary downloads from GitHub Releases, and bpick
  • atclone, atpull, and make build hooks
  • annexes, and the sbin and fbin shims they add
  • zinit times, zinit unload, and load tracking

Install those tools with your package manager instead, then initialize them in your .zshrc as their docs describe:

# zinit (.zshrc)
zinit ice as"command" from"gh-r" \
          atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
          atpull"%atclone" src"init.zsh"
zinit light starship/starship
# antidote: install starship once with your package manager (eg: brew install starship)
# then in .zshrc
eval "$(starship init zsh)"

A snippet from a plain URL, like a gist, isn’t a git repo. Save the file into a directory of your own and load it from there with using::

# zinit (.zshrc)
zinit snippet https://gist.githubusercontent.com/hightemp/5071909/raw/
# antidote: save the file as $ZDOTDIR/plugins/hightemp.zsh, then
# .zsh_plugins.txt
using:$ZDOTDIR/plugins
hightemp.zsh

Cleaning up

Once antidote is loading everything, remove the zinit lines from your .zshrc and delete zinit’s directory:

rm -rf ${XDG_DATA_HOME:-$HOME/.local/share}/zinit

If you set ZINIT_HOME or ZINIT[HOME_DIR] to somewhere else, delete that instead.

To compare startup times on your own machine, the antidote repo has tools/antidote-bench-zinit, which times both with the same plugins. For deferred loading, zsh-bench measures what a single zsh -i -c exit can’t.