Created
June 8, 2011 01:22
-
-
Save hmarr/1013596 to your computer and use it in GitHub Desktop.
post{,de}activate scripts for virtualenvwrapper
This file contains 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/zsh | |
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postactivate | |
# Remove virtual env from start of PS1 as it's in RPROMPT instead | |
PS1="$_OLD_VIRTUAL_PS1" | |
PROJECT_DIR="$HOME/projects/$(basename $VIRTUAL_ENV)" | |
if [ -d $PROJECT_DIR ]; then | |
# If we aren't already within the project dir, cd into it | |
if [[ ! `pwd` == "$PROJECT_DIR*" ]]; then | |
export PRE_VENV_ACTIVATE_DIR=`pwd` | |
cd "$PROJECT_DIR" | |
fi | |
fi | |
unset PROJECT_DIR |
This file contains 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/zsh | |
# Global virtualenvwrapper postactivate, lives in $WORKON_HOME/postdeactivate | |
if [ $PRE_VENV_ACTIVATE_DIR ]; then | |
cd $PRE_VENV_ACTIVATE_DIR | |
unset PRE_VENV_ACTIVATE_DIR | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment