Skip to content

Instantly share code, notes, and snippets.

@scalixte-mdsol
Forked from mihow/load_dotenv.sh
Created March 25, 2025 16:33
Show Gist options
  • Save scalixte-mdsol/1e8ab7af799d8589209741b25aae7c4d to your computer and use it in GitHub Desktop.
Save scalixte-mdsol/1e8ab7af799d8589209741b25aae7c4d 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