8297e21ed755b5d1205f9ed5937918adea6e960e

Author
Michael Aquilina <michaelaquilina@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

Merge pull request #52 from MichaelAquilina/faster_switching

Source the activate script directly for much faster switching

Diff

 1diff --git a/autoswitch_virtualenv.plugin.zsh b/autoswitch_virtualenv.plugin.zsh
 2index 5bcb040dedeb7958bc1917e761f318d87f99f108..919e49259a0ad00ae3fa291da0ca10eee1498e36 100644
 3--- a/autoswitch_virtualenv.plugin.zsh
 4+++ b/autoswitch_virtualenv.plugin.zsh
 5@@ -39,7 +39,8 @@ function _maybeworkon() {
 6         printf "Switching virtualenv: ${BOLD}${PURPLE}%s${NORMAL} " $1
 7      fi
 8 
 9-     workon "$1"
10+     # Much faster to source the activate file directly rather than use the `workon` command
11+     source "$HOME/.virtualenvs/$1/bin/activate"
12 
13      if [ -z "$AUTOSWITCH_SILENT" ]; then
14         _print_python_version
15@@ -54,7 +55,7 @@ function _maybepipenv() {
16         printf "Switching pipenv: ${BOLD}${PURPLE}%s${NORMAL} " "$(basename "$1")"
17      fi
18 
19-     . "$1"/bin/activate
20+     source "$1/bin/activate"
21 
22      if [ -z "$AUTOSWITCH_SILENT" ]; then
23         _print_python_version
24@@ -140,7 +141,7 @@ function _default_venv()
25 }
26 
27 
28-# remove virutal environment for current directory
29+# remove virtual environment for current directory
30 function rmvenv()
31 {
32   if [[ -f ".venv" ]]; then