Searching for Signal

the n01se blog

Load virtualenvwrapper on demand to speed up your shell

Loading takes too long:

 $ time source /usr/bin/
 real       0m1.034s
 user       0m0.625s
 sys        0m0.161s

If you load in your .bashrc, this means waiting an extra second every time you open a terminal. But you can avoid the delay by loading the functions on demand! The trick is to create stub functions workon, deactivate and mkvirtualenv that will load and then run the real function.

To make this work, save the following snippet as .bashrc.virtualenvwrapper in your home directory:

Then replace source in your .bashrc with:

source ~/.bashrc.virtualenvwrapper

This loads in about 1/100 of a second, and the real will load when you first invoke workon or mkvirtualenv.