Skip to content

Instantly share code, notes, and snippets.

@mihow
mihow / load_dotenv.sh
Last active February 25, 2025 06:15
Load environment variables from dotenv / .env file in Bash
# The initial version
if [ ! -f .env ]
then
export $(cat .env | xargs)
fi
# My favorite from the comments. Thanks @richarddewit & others!
set -a && source .env && set +a