Skip to content

Instantly share code, notes, and snippets.

@beaugunderson
Forked from kristjan/loadenv.sh
Created October 15, 2012 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beaugunderson/3896289 to your computer and use it in GitHub Desktop.
Save beaugunderson/3896289 to your computer and use it in GitHub Desktop.
Load a .env file into your current shell. Handy when you need to skirt Foreman.
function loadenv_inner() {
cat .env | while read line; do
echo export $line
done
}
function loadenv() {
if [ -f .env ]; then
eval `loadenv_inner`
else
echo No .env file in `pwd`
fi
}
@listenloop
Copy link

very handy. i follwed it up with

function mydir() {
cd ~/code/myproject && loadenv
}

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