Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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