Skip to content

Instantly share code, notes, and snippets.

@fbrnc
Created January 14, 2016 18:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbrnc/f41cbf48d635322111fe to your computer and use it in GitHub Desktop.
Save fbrnc/f41cbf48d635322111fe to your computer and use it in GitHub Desktop.
function dotenv --description 'Load environment variables from .env file'
set -l envfile ".env"
if [ (count $argv) -gt 0 ]
set envfile $argv[1]
end
if test -e $envfile
for line in (cat $envfile | grep -v '^#' | grep -v '^$')
set -xg (echo $line | cut -d = -f 1) (echo $line | cut -d = -f 2-)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment