7b478d75a3a0db466e78b6e46a0e468d64354618

Author
epelletier <enguerrand.pelletier@supinfo.com>
Committer
epelletier <enguerrand.pelletier@supinfo.com>
Date

Message

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 5faa1a823aa7c9764aef2eb95aed5fa16a5e3bb4..b3a3b56d5b5f5d2cdb8355199337dbab2be45714 100644
 3--- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
 4+++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
 5@@ -29,8 +29,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