Skip to content

Instantly share code, notes, and snippets.

@santaklouse
Last active January 23, 2026 10:17
Show Gist options
  • Select an option

  • Save santaklouse/381c3804a6a237445d389cf19282bdbd to your computer and use it in GitHub Desktop.

Select an option

Save santaklouse/381c3804a6a237445d389cf19282bdbd to your computer and use it in GitHub Desktop.
Load environment variables from .env file in Bash
#!/usr/bin/env bash
[ -f .env ] && export $(cat .env | grep -v '^#' | xargs)
# another variantwith source
# [ -f .env ] && set -a && source .env && set +a
# or
# [ -f .env ] && set -a && . .env && set +a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment