Skip to content

Instantly share code, notes, and snippets.

@muthuishere
Created October 25, 2024 15:06
Show Gist options
  • Save muthuishere/a87f8a71a761bf666ddbdc15e0827ff9 to your computer and use it in GitHub Desktop.
Save muthuishere/a87f8a71a761bf666ddbdc15e0827ff9 to your computer and use it in GitHub Desktop.
Load all the environment variables in the current session mac or linux

add it to .bashrc or .zshrc

alias loadenv='[ -f .env ] && export $(grep -v "^#" .env | xargs) && echo ".env variables have been loaded into the current session." || echo ".env file not found in the current directory."'

Upon any folder , which has a .env file , just call the alias loadenv it will load all the variables as environment variables in current session

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment