Importing env vars from .env file

by

There's a very quick way of importing all env vars defined in your .env file to the shell session you're currently in.

Adding this to your bash profile will allow you to run dotenv:

alias dotenv='export $(cat .env | grep -v ^# | xargs)'

To remove these variables you can also define unset-dotenv:

alias unset-dotenv='unset $(cat .env | grep -v ^# | sed -E "s/(.*)=.*/\1/" | xargs)'


Tags: env, dotenv, file, shell, bash, import, export, alias