๐ Eval
z-shell/z-a-evalโ
The output of a slow initialization command is redirected to a file located within the plugin/snippets directory and sourced while loading. The next time the plugin/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/snippets root directory which stores the commands output.
This cache is regenerated when:
- The plugin/snippet is updated.
- The cache file is removed.
- With the new Zi subcommand
recache.
The optional preceding
!flag means to store command output regardless of exit code. Otherwiseeval'โฆ'will avoid caching ouput of code which returns a non-zero exit code.
Synopsisโ
zi recache <plugin/snippet>
In order to enable tab completion for the new subcommand set the value Z_A_USECOMP=1 somewhere before loading this plugin.
zi atinit'Z_A_USECOMP=1' light-mode for z-shell/z-a-eval
Example Invocationsโ
Without z-a-evalโ
zi ice as"command" from"gh-r" mv"zoxide* -> zoxide" \
atclone"./zoxide init 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
With z-a-evalโ
zi ice as"command" from"gh-r" mv"zoxide* -> zoxide" \
eval"./zoxide init 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
Without Ziโ
if [[ "${+commands[kubectl]}" == 1 ]]; then
eval $(kubectl completion zsh)
fi
With Zi and z-a-evalโ
## Updated during `zi update`
zi ice id-as"kubectl_completion" has"kubectl" \
eval"kubectl completion zsh" run-atpull
zi light z-shell/null