From b7617b35ffd56243fa6d310886d8effe9f27bfc1 Mon Sep 17 00:00:00 2001 From: Jonathan Cremin Date: Fri, 10 Jul 2015 14:03:55 +0100 Subject: [PATCH 1/2] Check for autoenv_init function before trying to source autoenv. --- plugins/autoenv/autoenv.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index a8271849..edc16a4c 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,7 +1,7 @@ # Activates autoenv or reports its failure -if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then +if ! type autoenv_init &>/dev/null && ! source $HOME/.autoenv/activate.sh 2>/dev/null; then echo '-------- AUTOENV ---------' - echo 'Could not find ~/.autoenv/activate.sh.' + echo 'Could not find autoenv_init function or ~/.autoenv/activate.sh.' echo 'Please check if autoenv is correctly installed.' echo 'In the meantime the autoenv plugin is DISABLED.' echo '--------------------------' From c146853a5e529a522ca4cd6015cd55b796788806 Mon Sep 17 00:00:00 2001 From: Andrew Janke Date: Thu, 1 Oct 2015 19:29:59 -0400 Subject: [PATCH 2/2] autoenv: also look in the Homebrew installation location for it --- plugins/autoenv/autoenv.plugin.zsh | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index edc16a4c..c9f96811 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,12 +1,25 @@ # Activates autoenv or reports its failure -if ! type autoenv_init &>/dev/null && ! source $HOME/.autoenv/activate.sh 2>/dev/null; then - echo '-------- AUTOENV ---------' - echo 'Could not find autoenv_init function or ~/.autoenv/activate.sh.' - echo 'Please check if autoenv is correctly installed.' - echo 'In the meantime the autoenv plugin is DISABLED.' - echo '--------------------------' - return 1 +() { +if ! type autoenv_init >/dev/null; then + for d (~/.autoenv /usr/local/opt/autoenv); do + if [[ -e $d/activate.sh ]]; then + autoenv_dir=$d + break + fi + done + if [[ -z $autoenv_dir ]]; then + cat <&2 +-------- AUTOENV --------- +Could not locate autoenv installation. +Please check if autoenv is correctly installed. +In the meantime the autoenv plugin is DISABLED. +-------------------------- +END + return 1 + fi fi +} +[[ $? != 0 ]] && return $? # The use_env call below is a reusable command to activate/create a new Python # virtualenv, requiring only a single declarative line of code in your .env files.