Need help with autoenv?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

inishchith
4.8K Stars 247 Forks MIT License 236 Commits 23 Opened issues

Description

Directory-based environments. [Author @ken-reitz]

Services available

!
?

Need anything else?

Contributors list

# 25,196
nix
Markdow...
Arch Li...
portain...
46 commits
# 1,038
Python
Flask
Django
Heroku
14 commits
# 13,267
Ruby
Shell
mruby
jruby
8 commits
# 7,053
Flask
golang
Homebre...
raku
6 commits
# 89,679
Erlang
TeX
Zsh
Bash
4 commits
# 83,261
HTML
SQL
Zsh
Bash
3 commits
# 53,839
Python
Zsh
shell-e...
quran
3 commits
# 158,372
PHP
HTML
dummy
Zsh
2 commits
# 1,818
Redis
Shell
elm
Django
2 commits
# 148,582
google-...
CSS
angular...
Ada
2 commits
# 177,051
Python
Zsh
Bash
shell-s...
2 commits
# 202,047
Sublime...
SQL
C
Zsh
1 commit
# 169,418
CSS
Django
js
multipl...
1 commit
# 190,989
Scala
Rust
sensor-...
Zsh
1 commit
# 4,046
Zsh
zsh-plu...
zsh-plu...
bitbuck...
1 commit
# 27,186
pixel-a...
generat...
phantom...
gui-fra...
1 commit
# 108,456
cloudfl...
healthc...
Django
terrafo...
1 commit
# 125,646
Python
Postgre...
psql
postgre...
1 commit
# 162,447
python-...
python3
HTML
Zsh
1 commit
# 90,978
Ruby
Rails
C
Electro...
1 commit

Autoenv: Directory-based Environments Build Status

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:

image

What is it?

If a directory contains a

.env
file, it will automatically be executed when you
cd
into it. When enabled (set
AUTOENV_ENABLE_LEAVE
to a non-null string), if a directory contains a
.env.leave
file, it will automatically be executed when you leave it.

This is great for...

  • auto-activating virtualenvs
  • auto-deactivating virtualenvs
  • project-specific environment variables
  • making millions

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

.env
files beginning at the top.

Usage

Follow the white rabbit:

$ echo "echo 'whoa'" > project/.env
$ cd project
whoa

image

Install

Install it easily:

Mac OS X Using Homebrew

$ brew install autoenv
$ echo "source $(brew --prefix autoenv)/activate.sh" >> ~/.bash_profile

Using pip

$ pip install autoenv
$ echo "source `which activate.sh`" >> ~/.bashrc

Using git

$ git clone git://github.com/inishchith/autoenv.git ~/.autoenv
$ echo 'source ~/.autoenv/activate.sh' >> ~/.bashrc

Using AUR

Arch Linux users can install autoenv or autoenv-git with their favorite AUR helper.

You need to source activate.sh in your bashrc afterwards:

$ echo 'source /usr/share/autoenv/activate.sh' >> ~/.bashrc

Configuration

Before sourcing activate.sh, you can set the following variables:

  • AUTOENV_AUTH_FILE
    : Authorized env files, defaults to
    ~/.autoenv_authorized
  • AUTOENV_ENV_FILENAME
    : Name of the
    .env
    file, defaults to
    .env
  • AUTOENV_LOWER_FIRST
    : Set this variable to flip the order of
    .env
    files executed
  • AUTOENV_ENV_LEAVE_FILENAME
    : Name of the
    .env.leave
    file, defaults to
    .env.leave
  • 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

Shells

autoenv is tested on:

  • bash
  • zsh
  • dash
  • fish is supported by autoenv_fish
  • more to come

Alternatives

Direnv is an excellent alternative to autoenv, and includes the ability to unset environment variables as well. It also supports the fish terminal.

https://direnv.net

Disclaimer

Autoenv overrides

cd
. If you already do this, invoke
autoenv_init
within your custom
cd
after sourcing
activate.sh
.

Autoenv can be disabled via

unset cd
if you experience I/O issues with certain file systems, particularly those that are FUSE-based (such as
smbnetfs
).

Attributions

autoenv is one of @kennethreitz:org project and is now owned and maintained by @inishchith.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.