Skip to content

Instantly share code, notes, and snippets.

@hmarr
Created June 8, 2011 01:22
Show Gist options
  • Save hmarr/1013596 to your computer and use it in GitHub Desktop.
Save hmarr/1013596 to your computer and use it in GitHub Desktop.
post{,de}activate scripts for virtualenvwrapper
#!/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
#!/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