Skip to content

Instantly share code, notes, and snippets.

@chew-z
Created August 27, 2016 09:54
Show Gist options
  • Save chew-z/64af095a0c48f2a9244fe2af6f0be5e6 to your computer and use it in GitHub Desktop.
Save chew-z/64af095a0c48f2a9244fe2af6f0be5e6 to your computer and use it in GitHub Desktop.
Lazy loading virtualenv in zsh
# virtualenvwrapper
# lazy loading saves on shell startup time
workon() {
[ -z "$PROJECT_HOME" ] && {
unset -f workon;
export WORKON_HOME=$HOME/.virtualenvs;
export PROJECT_HOME=$HOME/Documents/Python;
source /usr/local/bin/virtualenvwrapper.sh
}
workon "$@"
}
# I have shaved c.a. 0.6-0.7 sec on terminal/zsh/oh-my-zsh startup
# 0.4sec through some cleanup in .zshrc - fpath, getting rid of compinit
# Another 0.3sec through this code which lazy loads virtualenv wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment