4c91f6d13e32d7389cae299d96f6778451a45fc8

Author
Serdar Dalgıç <sd@serdardalgic.org>
Committer
Serdar Dalgıç <sd@serdardalgic.org>
Date

Message

Add autoenv plugin, which adopts using Kenneth Reitz's autoenv into
oh-my-zsh.

Diff

 1diff --git a/lib/directories.zsh b/lib/directories.zsh
 2index 6c743e40ec943bbe3f188e187752e584c3bfa2db..93c6c176f5932d1ae1a063b26beb7b6fc8016934 100644
 3--- a/lib/directories.zsh
 4+++ b/lib/directories.zsh
 5@@ -29,6 +29,9 @@ cd () {
 6     cd ../../../..
 7   elif [[ "x$*" == "x......" ]]; then
 8     cd ../../../../..
 9+  elif [ -d ~/.autoenv ]; then
10+    source ~/.autoenv/activate.sh
11+    autoenv_cd "$@"
12   else
13     builtin cd "$@"
14   fi
15diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
16new file mode 100644
17index 0000000000000000000000000000000000000000..ca5666979cd7de508643295b7625835643847e8a
18--- /dev/null
19+++ b/plugins/autoenv/autoenv.plugin.zsh
20@@ -0,0 +1,18 @@
21+# The use_env call below is a reusable command to activate/create a new Python
22+# virtualenv, requiring only a single declarative line of code in your .env files.
23+# It only performs an action if the requested virtualenv is not the current one.
24+use_env() {
25+    typeset venv
26+    venv="$1"
27+    if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
28+        if workon | grep -q "$venv"; then
29+            workon "$venv"
30+        else
31+            echo -n "Create virtualenv $venv now? (Yn) "
32+            read answer
33+            if [[ "$answer" == "Y" ]]; then
34+                mkvirtualenv "$venv"
35+            fi
36+        fi
37+    fi
38+}