🌀 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:
- The plugin or snippet is updated.
- The cache file is removed.
- When running
zi recache
.
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
- No Eval + Zi
- Eval + Zi
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
zi ice as"command" from"gh-r" \
eval"./zoxide init --cmd x zsh"
zi light ajeetdsouza/zoxide
zi ice eval"dircolors -b LS_COLORS" \
atload'zstyle ":completion:*" list-colors ${(s.:.)LS_COLORS}'
zi light trapd00r/LS_COLORS
- No Zi + Eval
- Zi + Eval
if [[ "${+commands[kubectl]}" == 1 ]]; then
eval $(kubectl completion zsh)
fi
zi ice id-as"kubectl_completion" has"kubectl" \
eval"kubectl completion zsh" run-atpull
zi light z-shell/null
Install eval
- Default
- Enable Completion
Add the following snippet in the .zshrc
file:
zi light z-shell/z-a-eval
Add the following snippet in the .zshrc
file:
Set value
Z_A_USECOMP=1
to enable TAB completion for subcommandrecache
.
zi ice atinit'Z_A_USECOMP=1'
zi light z-shell/z-a-eval