Skip to content

Instantly share code, notes, and snippets.

@acdha
Created March 12, 2014 21:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acdha/9517060 to your computer and use it in GitHub Desktop.
Save acdha/9517060 to your computer and use it in GitHub Desktop.
Global virtualenvwrapper hooks which add a project's bin directory to the PATH any time you activate a virtualenv
#!/bin/bash
# This hook is run after every virtualenv is activated.
VIRTUALENV_PROJECT_FILE="$VIRTUAL_ENV/$VIRTUALENVWRAPPER_PROJECT_FILENAME";
if [ -f $VIRTUALENV_PROJECT_FILE ]; then
export VIRTUALENV_PROJECT=$(cat $VIRTUALENV_PROJECT_FILE);
if [ -d "$VIRTUALENV_PROJECT/bin" ]; then
export PATH="$VIRTUALENV_PROJECT/bin":$PATH
fi
fi
if [ ! -z "$VIRTUALENV_PROJECT" ]; then
pushd $VIRTUALENV_PROJECT
fi
#!/bin/bash
# This hook is run after every virtualenv is deactivated.
# Clean up after postactive
unset VIRTUALENV_PROJECT_FILE VIRTUALENV_PROJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment