跳转至

zsh_virtualenvwrapper

Source

Installing Virtualenv & Virtualenvwrapper

pip install virtualenv virtualenvwrapper

You'll need to tell ZSH where virtualenvs need to be put

In ~/.zshrc add

# Virtualenvwrapper things
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

Showing the virtualenv name

By default the ZSH virtualenv plugin hides the virtualenv name. I've no idea why...

nano ~/.oh-my-zsh/plugins/virtualenv/virtualenv.plugin.zsh

Within that file you'll see

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

Hash out export VIRTUAL_ENV_DISABLE_PROMPT=1 and reload ZSH.

Test that all working by doing something like

~ mkvirtualenv test2

You should see

New python executable in /Users/edd/.virtualenvs/test2/bin/python2.7
Also creating executable in /Users/edd/.virtualenvs/test2/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/edd/.virtualenvs/test2/bin/get_env_details
(test2) ➜  ~ pip install something_awesome_inside_my_obvious_virtualenv