Request for evalcache Demo and .zshrc Usage Example
Hello,
Thank you for developing evalcache! I’m trying to improve my zsh startup time using your plugin but am struggling with setting it up correctly in my .zshrc. Specifically, I’d like to cache some commands that slow down the shell load time.
I’ve installed evalcache using oh-my-zsh by cloning it into the custom plugins folder and adding evalcache to my plugin list. However, I’m unsure how to modify my .zshrc to make full use of _evalcache.
Would it be possible for you to provide a demo or example configuration showing how to apply _evalcache to typical commands? Here’s an example of my current setup:
# Enable Powerlevel10k instant prompt
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Path to oh-my-zsh
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
# Plugins
plugins=(git sudo zsh-syntax-highlighting zsh-autosuggestions evalcache)
# Load oh-my-zsh
source $ZSH/oh-my-zsh.sh
# Conda initialize (example of slow-loading command)
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# Custom paths
export PATH="/path/to/software/bin:$PATH"
Questions:
- How should I apply
_evalcacheto commands likecondainitialization to ensure they’re cached? - Could you provide a basic demo of
evalcacheusage in.zshrcfor common scenarios like initializingconda, Powerlevel10k, or other plugins?
Thank you for any guidance, and for a tool that could greatly improve my workflow!
Hi sorry I just saw this.
Unless I'm misreading, in your case the eval line that is slow is effectively:
eval "$(/opt/anaconda3/bin/conda shell.zsh hook 2> /dev/null)"
I'm not sure if/how the redirecting stderr to /dev/null/ in your example changes things, but in a typical case you would simply rewrite as:
_evalcache /opt/anaconda3/bin/conda shell.zsh hook 2> /dev/null
LMK if that works or if the redirection breaks it.