miniconda安装完后,zsh命令行主题不显示conda的环境name
编辑主题文件
vim ~/.oh-my-zsh/themes/bullet-train.zsh-theme
1 2 3 4 5 6 7 8 9 10 11 12 13
| # Virtualenv: current working virtualenv prompt_virtualenv() { local virtualenv_path="$VIRTUAL_ENV" # 加入Conda环境变量判断逻辑 if [[ -n $CONDA_DEFAULT_ENV && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then prompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_CONDA_PREFIX" $(basename $CONDA_DEFAULT_ENV)" elif [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then prompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_VIRTUALENV_PREFIX" $(basename $virtualenv_path)" elif which pyenv &> /dev/null; then prompt_segment $BULLETTRAIN_VIRTUALENV_BG $BULLETTRAIN_VIRTUALENV_FG $BULLETTRAIN_VIRTUALENV_PREFIX" $(pyenv version | sed -e 's/ (set.*$//' | tr '\n' ' ' | sed 's/.$//')" fi }
|
修改保存.
vim ~/.zshrc
1 2 3 4 5 6 7
| # prompt变量中增加 BULLETTRAIN_PROMPT_ORDER=( virtualenv #加上 time dir git )
|
执行source ~/.zshrc