@@ -5,7 +5,7 @@ export _VIRTUALENVWRAPPER_API="$_VIRTUALENVWRAPPER_API mkvirtualenv rmvirtualenv
55
66if [ -z " $VIRTUALENVWRAPPER_SCRIPT " ]
77then
8- export VIRTUALENVWRAPPER_SCRIPT=" $( which virtualenvwrapper.sh) "
8+ export VIRTUALENVWRAPPER_SCRIPT=" $( command \ w hich virtualenvwrapper.sh) "
99fi
1010if [ -z " $VIRTUALENVWRAPPER_SCRIPT " ]
1111then
1414
1515# Load the real implementation of the API from virtualenvwrapper.sh
1616function virtualenvwrapper_load {
17- source " $VIRTUALENVWRAPPER_SCRIPT "
17+ # Only source the script once.
18+ # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets
19+ # a real completion.
20+ if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]
21+ then
22+ # NOTE: For Zsh, I have tried to unset any auto-load completion.
23+ # (via `compctl + $(echo ${_VIRTUALENVWRAPPER_API})`.
24+ # But this does not appear to work / triggers a crash.
25+ source " $VIRTUALENVWRAPPER_SCRIPT "
26+ VIRTUALENVWRAPPER_LAZY_LOADED=1
27+ fi
1828}
1929
2030# Set up "alias" functions based on the API definition.
@@ -41,4 +51,6 @@ function virtualenvwrapper_setup_lazy_completion {
4151}
4252
4353virtualenvwrapper_setup_lazy_loader
54+ # Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
55+ # It also needs a second invocation, because the first one only sets up the real completion.
4456virtualenvwrapper_setup_lazy_completion
0 commit comments