Merge pull request #1565 from serdardalgic/autoenv-plugin
Add autoenv plugin, which adopts using Kenneth Reitz's autoenv.
Diff
1diff --git a/lib/directories.zsh b/lib/directories.zsh
2index b3a478d47a8ee5b949bc77b194d148e589ee7998..1896945f46948f68ec5e3d67b54e36429d42c910 100644
3--- a/lib/directories.zsh
4+++ b/lib/directories.zsh
5@@ -30,6 +30,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+}