Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delay sourcing virtualenvwrapper.sh until first call to workon
## delay sourcing venv to workon call
## replace "source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh"
## with below block
function load_env {
if [ type -p workon &> /dev/null ]; then
# nothing, source is loaded
workon "$@"
else
unalias workon
source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh
workon "$@"
fi
}
alias workon="load_env"
@warvariuc

This comment has been minimized.

Copy link

warvariuc commented Nov 8, 2013

http://virtualenvwrapper.readthedocs.org/en/latest/install.html#lazy-loading
I did:

export PROJECT_HOME=~/projects/
export WORKON_HOME=~/projects/venv
#export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUAL_ENV_DISABLE_PROMPT=1

if [ -f `which virtualenvwrapper_lazy.sh` ]; then
    source `which virtualenvwrapper_lazy.sh`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.