conda带来的zsh启动慢

title

平时使用中发现zsh启动延迟大到需要等上好几秒,翻过改的乱七八糟的zshrc发现是conda在拖慢启动速度。

虽然最便捷的方法是不用conda,但作业又经常用到conda的环境。

这里选择为conda绑定alias,在需要时启动。

1
2
3
# in .zshrc add

alias ci='source ~/.config/zsh/conda.zsh'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# in conda.zsh

#!/usr/bin/zsh
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/miniconda3/etc/profile.d/conda.sh" ]; then
. "/opt/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<