Commits

Doug Hellmann committed f807667 Merge with conflicts

Merge remote-tracking branch 'blueyed/master' into merge-blueyed

Conflicts:
virtualenvwrapper_lazy.sh

Change-Id: I611e4f302e9dbc39b0a7a848ee5574934dd0537f

  • Participants
  • Parent commits b97e1b9, 7c94c07

Comments (0)

Files changed (2)

virtualenvwrapper.sh

 virtualenvwrapper.sh: There was a problem running the initialization hooks. 
 
 If Python could not import the module virtualenvwrapper.hook_loader,
-check that virtualenv has been installed for
+check that virtualenvwrapper has been installed for
 VIRTUALENVWRAPPER_PYTHON=$VIRTUALENVWRAPPER_PYTHON and that PATH is
 set properly.
 EOF

virtualenvwrapper_lazy.sh

 
 if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
 then
-    export VIRTUALENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)"
+    export VIRTUALENVWRAPPER_SCRIPT="$(command \which virtualenvwrapper.sh)"
 fi
 if [ -z "$VIRTUALENVWRAPPER_SCRIPT" ]
 then
 
 # Load the real implementation of the API from virtualenvwrapper.sh
 function virtualenvwrapper_load {
-    source "$VIRTUALENVWRAPPER_SCRIPT"
+    # Only source the script once.
+    # We might get called multiple times, because not all of _VIRTUALENVWRAPPER_API gets
+    # a real completion.
+    if [ -z $VIRTUALENVWRAPPER_LAZY_LOADED ]; then
+        if [ -n "$ZSH_VERSION" ] ; then
+            # Tried to unset any auto-load completion, does not appear to work/triggers a crash
+            # compctl + $(echo ${_VIRTUALENVWRAPPER_API})
+        fi
+        source "$VIRTUALENVWRAPPER_SCRIPT"
+        VIRTUALENVWRAPPER_LAZY_LOADED=1
+    fi
 }
 
 # Set up "alias" functions based on the API definition.
 }
 
 virtualenvwrapper_setup_lazy_loader
+# Does not really work. Cannot be reset in zsh to fallback to files (e.g. mkvirtualenv).
+# It also needs a second invocation, because the first one only sets up the real completion.
 virtualenvwrapper_setup_lazy_completion