Skip to content

Instantly share code, notes, and snippets.

@douganger
Created October 27, 2015 19:25
Show Gist options
  • Save douganger/a0a90769f422e1c57f51 to your computer and use it in GitHub Desktop.
Save douganger/a0a90769f422e1c57f51 to your computer and use it in GitHub Desktop.
# Find the innermost directory with an env and activate it.
env_root=$(pwd -P 2>/dev/null || command pwd)
while [ ! -e "$env_root/env" ]; do
env_root=${env_root%/*}
if [ "$env_root" = "" ]; then break; fi
done
if [ -n "$env_root" ]; then
source "$env_root/env/bin/activate"
else
if [ -n "$VIRTUAL_ENV" ] ; then deactivate; fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment