Skip to content

Instantly share code, notes, and snippets.

@wyllie
Created June 20, 2018 19:59
Show Gist options
  • Save wyllie/164cab4cbc4b5e41bfb71d623f7bec16 to your computer and use it in GitHub Desktop.
Save wyllie/164cab4cbc4b5e41bfb71d623f7bec16 to your computer and use it in GitHub Desktop.
Python Virtual Environment Config
# Python environment
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Projects
# Set up virtual wrapper env
source /usr/local/bin/virtualenvwrapper.sh
# for testing, set pytest to verbose by default
alias pytest='pytest -v'
# when switching to a new directory, this will set the python
# virtual environment to the contents of a file called .venv
# located in that directory. That virtual environment will
# remain active until you switch to another directory with a
# .venv file. You can still use deactivate or workon to
# to change/deactivate the virtual environment
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}python_venv_prompt"
function python_venv_prompt()
{
if [ "$PWD" != "$MYOLDPWD" ]; then
MYOLDPWD="$PWD"
test -e .venv && workon `cat .venv`
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment