470e1a1ecfac3dcc8804c1e786dc4b7abeb710b9

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1173 from walkah/virtualenvwrapper-osx-fix

Readlink is different on OS X

Diff

 1diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
 2index afdad1beaa401818fd4ac4162bc4e7a23afb83ff..a93c8e8633351f5e31904d2c3d681043ced94739 100644
 3--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
 4+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
 5@@ -10,11 +10,9 @@ for wrapsource in "/usr/local/bin/virtualenvwrapper.sh" "/etc/bash_completion.d/
 6       # by placing a .venv file in the project root with a virtualenv name in it
 7       function workon_cwd {
 8           # Check that this is a Git repo
 9-          GIT_DIR=`git rev-parse --git-dir 2> /dev/null`
10+          PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
11           if (( $? == 0 )); then
12-              # Find the repo root and check for virtualenv name override
13-              GIT_DIR=`readlink -f $GIT_DIR`
14-              PROJECT_ROOT=`dirname "$GIT_DIR"`
15+              # Check for virtualenv name override
16               ENV_NAME=`basename "$PROJECT_ROOT"`
17               if [[ -f "$PROJECT_ROOT/.venv" ]]; then
18                   ENV_NAME=`cat "$PROJECT_ROOT/.venv"`
19@@ -30,6 +28,7 @@ for wrapsource in "/usr/local/bin/virtualenvwrapper.sh" "/etc/bash_completion.d/
20               # Note: this only happens if the virtualenv was activated automatically
21               deactivate && unset CD_VIRTUAL_ENV
22           fi
23+          unset PROJECT_ROOT
24       }
25 
26       # New cd function that does the virtualenv magic