Skip to content

Instantly share code, notes, and snippets.

@johnthedebs
Forked from valyagolev/Instructions.markdown
Last active April 18, 2017 18:34
Show Gist options
  • Save johnthedebs/1155313 to your computer and use it in GitHub Desktop.
Save johnthedebs/1155313 to your computer and use it in GitHub Desktop.
Virtualenv in new Terminal windows/tabs

Run these commands in your console, they will edit necessary files:

echo 'basename "$VIRTUAL_ENV" > ~/.last_venv' >> $VIRTUALENVWRAPPER_HOOK_DIR/postactivate
echo 'rm ~/.last_venv' >> $VIRTUALENVWRAPPER_HOOK_DIR/postdeactivate
touch ~/.last_venv

Then open your ~/.bashrc or ~/.profile or whatever your shell uses and append:

if [ -e ~/.last_venv ]; then
    workon `cat ~/.last_venv`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment