Skip to content

Instantly share code, notes, and snippets.

@anhkind
Forked from mihow/load_dotenv.sh
Created July 6, 2025 10:26
Show Gist options
  • Save anhkind/6f54dad898a7539bee8d19cfa001fd34 to your computer and use it in GitHub Desktop.
Save anhkind/6f54dad898a7539bee8d19cfa001fd34 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