Autoenv will automatically execute certain commands whenever you “cd” into a directory containing a “.env” file. This is an excellent command-line tool for enhancing productivity. My most common use for Autoenv is activating virtual environments or setting environment variables.

Install with Homebrew:

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

This can also be installed using pip or git. The alternative methods can be found here.

Using Autoenv

Once you get autoenv installed, simply create a .env file in your project directory:

touch .env

Open this file with an editor. From here, you can enter any command you need to execute:

echo 'it works!'
source venv/bin/activate

Posted in