Skip to content

Instantly share code, notes, and snippets.

@Bouke

Bouke/postactivate

Created Jan 8, 2014
Embed
What would you like to do?
Python virtualenvwrapper
#!/bin/bash
# This hook is run after every virtualenv is activated.
#create project directory and cd into it
env_name="`basename \"$VIRTUAL_ENV\"`"
env_name="${env_name/-py3/}"
pwd_root="$HOME/Sites/$env_name"
if [ ! -d "$pwd_root" ] ; then
echo "Creating directory $pwd_root"
mkdir "$pwd_root"
fi
cd "$pwd_root"
#colorful env name
PS1="\[\033[33m\](`basename \"$VIRTUAL_ENV\"`)$_OLD_VIRTUAL_PS1"
@Bouke

This comment has been minimized.

Copy link
Owner Author

@Bouke Bouke commented Jan 8, 2014

This hook will create a folder with the same name as the virtual environment in ~/Sites/. If the name contains -py3, that's stripped from the name. This allows you to share a folder for between Python 2 and 3 virtual environments.

The last command uses some lively colors for the name of the virtual environment in your prompt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.