Directory-based environments. [Author @ken-reitz]
Magic per-project shell environments. Very pretentious.
Note: you should probably use direnv instead. Simply put, it is higher quality software. But, autoenv is still great, too. Maybe try both? :)
This image sums up the relationship between the two projects, very well:
If a directory contains a
.envfile, it will automatically be executed when you
cdinto it. When enabled (set
AUTOENV_ENABLE_LEAVEto a non-null string), if a directory contains a
.env.leavefile, it will automatically be executed when you leave it.
This is great for...
You can also nest envs within each other. How awesome is that!?
When executing, autoenv, will walk up the directories until the mount point and execute all
.envfiles beginning at the top.
Follow the white rabbit:
$ echo "echo 'whoa'" > project/.env $ cd project whoa
Install it easily:
$ brew install autoenv $ echo "source $(brew --prefix autoenv)/activate.sh" >> ~/.bash_profile
$ pip install autoenv $ echo "source `which activate.sh`" >> ~/.bashrc
$ git clone git://github.com/inishchith/autoenv.git ~/.autoenv $ echo 'source ~/.autoenv/activate.sh' >> ~/.bashrc
You need to source activate.sh in your bashrc afterwards:
$ echo 'source /usr/share/autoenv/activate.sh' >> ~/.bashrc
Before sourcing activate.sh, you can set the following variables:
AUTOENV_AUTH_FILE: Authorized env files, defaults to
AUTOENV_ENV_FILENAME: Name of the
.envfile, defaults to
AUTOENV_LOWER_FIRST: Set this variable to flip the order of
AUTOENV_ENV_LEAVE_FILENAME: Name of the
.env.leavefile, defaults to
AUTOENV_ENABLE_LEAVE: Set this to a non-null string in order to enable source env when leaving
AUTOENV_ASSUME_YES: Set this variable to silently authorize the initialization of new environments
autoenv is tested on:
Direnv is an excellent alternative to autoenv, and includes the ability to unset environment variables as well. It also supports the fish terminal.
cd. If you already do this, invoke
autoenv_initwithin your custom
Autoenv can be disabled via
unset cdif you experience I/O issues with certain file systems, particularly those that are FUSE-based (such as