summaryrefslogtreecommitdiff
path: root/plugins/autoenv
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/autoenv')
-rw-r--r--plugins/autoenv/README.md14
-rw-r--r--plugins/autoenv/autoenv.plugin.zsh28
2 files changed, 35 insertions, 7 deletions
diff --git a/plugins/autoenv/README.md b/plugins/autoenv/README.md
new file mode 100644
index 000000000..de3881774
--- /dev/null
+++ b/plugins/autoenv/README.md
@@ -0,0 +1,14 @@
+# Autoenv plugin
+
+This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
+
+To use it, add `autoenv` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... autoenv)
+```
+## Requirements
+
+In order to make this work, you will need to have the autoenv installed.
+
+More info on the usage and install: https://github.com/inishchith/autoenv
diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
index a8271849e..3c1b0fafc 100644
--- a/plugins/autoenv/autoenv.plugin.zsh
+++ b/plugins/autoenv/autoenv.plugin.zsh
@@ -1,12 +1,26 @@
# Activates autoenv or reports its failure
-if ! source $HOME/.autoenv/activate.sh 2>/dev/null; then
- echo '-------- AUTOENV ---------'
- echo 'Could not find ~/.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 ~/.local/bin /usr/local/opt/autoenv /usr/local/bin); do
+ if [[ -e $d/activate.sh ]]; then
+ autoenv_dir=$d
+ break
+ fi
+ done
+ if [[ -z $autoenv_dir ]]; then
+ cat <<END >&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
+ source $autoenv_dir/activate.sh
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.