Skip to content

Instantly share code, notes, and snippets.

@pmclanahan
Created February 26, 2013 01:53
Show Gist options
  • Save pmclanahan/5035134 to your computer and use it in GitHub Desktop.
Save pmclanahan/5035134 to your computer and use it in GitHub Desktop.
postactivate hook for virtualenvwrapper to add a project's `bin` directory to the path while the venv is active.
get_project_dir () {
virtualenvwrapper_verify_workon_home || return 1
virtualenvwrapper_verify_active_environment || return 1
if [ -f "$VIRTUAL_ENV/.project" ]
then
project_dir=$(cat "$VIRTUAL_ENV/.project")
if [ ! -z "$project_dir" ]
then
# will be cleaned up by virtualenvwrapper
export PATH="${project_dir}/bin/:$PATH"
# find new programs (possibly ZSH specific)
hash -r
fi
fi
return 0
}
get_project_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment