【解决】venv 的名字在 zsh prompt 中不显示

venv 的名字在 zsh prompt 中不显示

➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] python3 -m venv lyj_venv
➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] source ./lyj_venv/bin/activate
➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] python

我的 zsh 使用的是 robbyrussell 主题,进入到 ~/.oh-my-zsh/plugins/virtualenv

➜ liyongjiandeMBP.lan [/Users/liyongjian/.oh-my-zsh/plugins/virtualenv] git:(master) ✗ cat virtualenv.plugin.zsh
function virtualenv_prompt_info(){
[[ -n ${VIRTUAL_ENV} ]] || return
echo "${ZSH_THEME_VIRTUALENV_PREFIX:=[}${VIRTUAL_ENV:t}${ZSH_THEME_VIRTUALENV_SUFFIX:=]}"
}

# disables prompt mangling in virtual_env/bin/activate
export VIRTUAL_ENV_DISABLE_PROMPT=1

将 `export VIRTUAL_ENV_DISABLE_PROMPT=1` 注释掉,然后 source ~/.zshrc

➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] python3 -m venv lyj_venv
➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] source ./lyj_venv/bin/activate
(lyj_venv) ➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj] python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
(lyj_venv) ➜ liyongjiandeMBP.lan [/Users/liyongjian/lyj]

参考:https://stackoverflow.com/questions/38928717/virtualenv-name-not-show-in-zsh-prompt

posted @ 2019-04-10 10:36  liyongjian5179  阅读(985)  评论(0编辑  收藏  举报