0be21f025e6f77e936b7b373f1a2a14b4a7145ba

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

Message

Merge pull request #4440 from apjanke/autoenv-homebrew

autoenv: support homebrew-installed autoenv

Diff

 1diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
 2index a8271849e3004255b2acb29b6cdefa089e917ddb..c9f968118706b4e882fe61cd1bd494cc01c62ac7 100644
 3--- a/plugins/autoenv/autoenv.plugin.zsh
 4+++ b/plugins/autoenv/autoenv.plugin.zsh
 5@@ -1,12 +1,25 @@
 6 # Activates autoenv or reports its failure
 7-if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then
 8-  echo '-------- AUTOENV ---------'
 9-  echo 'Could not find ~/.autoenv/activate.sh.'
10-  echo 'Please check if autoenv is correctly installed.'
11-  echo 'In the meantime the autoenv plugin is DISABLED.'
12-  echo '--------------------------'
13-  return 1
14+() {
15+if ! type autoenv_init >/dev/null; then
16+  for d (~/.autoenv /usr/local/opt/autoenv); do
17+    if [[ -e $d/activate.sh ]]; then
18+      autoenv_dir=$d
19+      break
20+    fi
21+  done
22+  if [[ -z $autoenv_dir ]]; then 
23+    cat <<END >&2
24+-------- AUTOENV ---------
25+Could not locate autoenv installation.
26+Please check if autoenv is correctly installed.
27+In the meantime the autoenv plugin is DISABLED.
28+--------------------------
29+END
30+    return 1
31+  fi
32 fi
33+}
34+[[ $? != 0 ]] && return $?
35 
36 # The use_env call below is a reusable command to activate/create a new Python
37 # virtualenv, requiring only a single declarative line of code in your .env files.