Skip to main content

🌀 Eval

The output of a slow initialization command is redirected to a file located within the plugin or snippets directory and sourced while loading. The next time the plugin or snippet is loaded, this file will be sourced skipping the need to run the initialization command.

The ice-modifier eval'â€Ļ' provided and handled by this annex creates a cache in the plugin or snippets directory which stores the output of the command and the cache is regenerated when:

  1. The plugin or snippet is updated.
  2. The cache file is removed.
  3. When running zi recache.
note

The optional preceding ! flag means to store command output regardless of exit code. Otherwise eval'â€Ļ' will avoid caching the output of code which returns a non-zero exit code.

Example invocations​

zi ice as"command" from"gh-r" \
atclone"./zoxide init --cmd x zsh > init.zsh" \
atpull"%atclone" src"init.zsh" nocompile'!'
zi light ajeetdsouza/zoxide
zi ice atclone"dircolors -b LS_COLORS > init.zsh" \
atpull"%atclone" pick"init.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS}'
zi light trapd00r/LS_COLORS
if [[ "${+commands[kubectl]}" == 1 ]]; then
eval $(kubectl completion zsh)
fi

Install eval​

Add the following snippet in the .zshrc file:

zi light z-shell/z-a-eval

This will register subcommand recache and eval'â€Ļ' ice-modifier.