环境macOS。python
当我初次安装anaconda时,在terminal中(使用bash)会显示,表示我当前正在conda的base环境中。切换后(如使用命令conda activate python2),能够成功观察到变化
bash
但在使用zsh时,却不显示行头的(python2)提示符,这使得如何知晓当前处在哪一个环境变得很麻烦。命令行
通过搜索研究,发现问题以下:blog
我使用的配置是zsh + oh-my-zsh + powerlevel9k (基本都是默认设置), 在powerlevel0k.zsh-theme 文件中(在个人本地目录下路径为/Users/chzhengy/.oh-my-zsh/custom/themes/powerlevel9k/powerlevel0k.zsh-theme ), 有两行参数POWERLEVEL9K_LEFT_PROMPT_ELEMENTS 和 POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS,其默认设置为:terminal
defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)it
括号中的内容即为在iterm中命令行里抬头会显示哪些内容。咱们须要将anaconda参数加到咱们想要的位置(左右皆可,看我的喜爱),我选择将其加到左侧第一个的位置,所以修改后为zsh
defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda context dir vcs)
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)配置
保存设置后从新启动iterm便可virtualenv
效果如图:搜索
若是使用virtualenv时出现一样不显示的问题,方法如上。在参数行新增:
defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(virtualenv anaconda context dir vcs)
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
便可解决