Created
January 8, 2014 18:37
-
-
Save Bouke/8321952 to your computer and use it in GitHub Desktop.
Python virtualenvwrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.