如何让 zsh shell 在激活 micromamba 后显示环境标题?

如何让 zsh shell 在激活 micromamba 后显示环境标题?

我试图设置zsh为在激活环境时在提示中显示环境名称。

@allerpi 的这个建议 不适合我。

micromamba activate

无论如何都不会改变提示。

结局~/.zshrc如下

# >>> mamba initialize >>>
# !! Contents within this block are managed by 'mamba init' !!
export MAMBA_EXE='/home/iudaevmd/.local/bin/micromamba';
export MAMBA_ROOT_PREFIX='/home/iudaevmd/micromamba';
__mamba_setup="$("$MAMBA_EXE" shell hook --shell zsh --root-prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__mamba_setup"
else
    alias micromamba="$MAMBA_EXE"  # Fallback on help from mamba activate
fi
unset __mamba_setup
# <<< mamba initialize <<<
alias mamba=micromamba

# Determines prompt modifier if and when a conda environment is active
precmd_conda_info() {
  if [[ -n $CONDA_DEFAULT_ENV ]]; then
    CONDA_ENV="($CONDA_DEFAULT_ENV) "
  # When no conda environment is active, don't show anything
  else
    CONDA_ENV=""
  fi
}

# Run the previously defined function before each prompt
precmd_functions+=( precmd_conda_info )

# Allow substitutions and expansions in the prompt
setopt prompt_subst
PROMPT='%F{cyan}$CONDA_ENV%f%F{green}%n%f %B%F{blue}%1~%f%b $ '


我能做些什么?

相关内容