-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
very handy. i follwed it up with
function mydir() {
cd ~/code/myproject && loadenv
}