0a8ca6adff743d38c145611377a72874d4e35414
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #3918 from cbazin/master
Detect the .venv in any parent directory of the current directory
Diff
1diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
2index b2c804edb298a4fbb2ff3291235e948522778689..9fd0d3d8fd6163af1c6709830885eeff411fec02 100644
3--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
4+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
5@@ -37,8 +37,11 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
6 if [ ! $WORKON_CWD ]; then
7 WORKON_CWD=1
8 # Check if this is a Git repo
9- PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null`
10- if (( $? != 0 )); then
11+ PROJECT_ROOT=`pwd`
12+ while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" ]]; do
13+ PROJECT_ROOT=`realpath $PROJECT_ROOT/..`
14+ done
15+ if [[ "$PROJECT_ROOT" == "/" ]]; then
16 PROJECT_ROOT="."
17 fi
18 # Check for virtualenv name override