Skip to content

Instantly share code, notes, and snippets.

@iezed
Forked from mihow/load_dotenv.sh
Created August 18, 2024 16:04
Show Gist options
  • Save iezed/db31dbf05644c4bd969259a29754f8aa to your computer and use it in GitHub Desktop.
Save iezed/db31dbf05644c4bd969259a29754f8aa to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment