Skip to content

Instantly share code, notes, and snippets.

@jamesandariese
Created November 3, 2015 17:41
Show Gist options
  • Save jamesandariese/28f29c9d6e5661e973af to your computer and use it in GitHub Desktop.
Save jamesandariese/28f29c9d6e5661e973af to your computer and use it in GitHub Desktop.
autoactivating venv
#!/bin/sh
# add the following to your .bash_profile
# PROMPT_COMMAND=". ~/bin/autoactivate;$PROMPT_COMMAND"
# when you want to work on a project with a venv,
# run virtualenv venv in the base directory.
# awesomeness will ensue.
pushd . > /dev/null
# this might need to be /usr/bin/true for a mac
while /bin/true;do
if [ -d 'venv' ];then
. venv/bin/activate
break
fi
[ .. -ef . ] && break
[ . -ef ~ ] && break
cd ..
done
popd > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment