Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Add autoenv plugin, which adopts using Kenneth Reitz's autoenv. #1565

merged 1 commit into from

3 participants



I've added a plugin for using autoenv. When cd'ed into a directory, autoenv checks whether there is an .env file in this directory; if there is one it executes the contents of this .env file.

This commit changes the overridden cd () in lib/directories.zsh. The plugin assumes autoenv is installed under ~/.autoenv a.k.a autoenv is git checked-out to .autoenv. I'm open to any suggestions about that.

The use_env function in the plugin is used to auto-activate virtualenv and needs virtualenvwrapper. The code is taken from

For the autoenv users, I think this plugin would help much. I'd be pleased if you merge the code into master branch. I'd also appreciate any comments on how to improve the code.




For the Plugins wiki page, this section can be added:

=== autoenv ===
This plugin assumes you installed autoenv to ~/.autoenv directory. It includes the auto-activate virtualenv code which needs virtualenvwrapper.


Ping? Any comments(positive or negative) on this plugin?


Here is my feedback: I'm using homebrew and pip, so assuming autoenv is installed under ~/.autoenv is not useful since none of these package managers do so. Does it give any errors if it can't locate the installation? (haven't tried it yet but the plugin source does not say so as far as I read).

I guess pip has it under /usr/local/bin/ and homebrew has it under /usr/local/opt/autoenv/ so maybe a fallback logic would handle it better.


Sorry for replying back that late. @ahmetalpbalkan Yeah, you're right. I'll take a look at it asap.

@robbyrussell robbyrussell merged commit 685c746 into from

@serdardalgic took this as is... get some users... make it better as necessary!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 0 deletions.
  1. +3 −0  lib/directories.zsh
  2. +18 −0 plugins/autoenv/autoenv.plugin.zsh
3  lib/directories.zsh
@@ -29,6 +29,9 @@ cd () {
cd ../../../..
elif [[ "x$*" == "x......" ]]; then
cd ../../../../..
+ elif [ -d ~/.autoenv ]; then
+ source ~/.autoenv/
+ autoenv_cd "$@"
builtin cd "$@"
18 plugins/autoenv/autoenv.plugin.zsh
@@ -0,0 +1,18 @@
+# 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.
+# It only performs an action if the requested virtualenv is not the current one.
+use_env() {
+ typeset venv
+ venv="$1"
+ if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
+ if workon | grep -q "$venv"; then
+ workon "$venv"
+ else
+ echo -n "Create virtualenv $venv now? (Yn) "
+ read answer
+ if [[ "$answer" == "Y" ]]; then
+ mkvirtualenv "$venv"
+ fi
+ fi
+ fi
Something went wrong with that request. Please try again.