From 1697dd555fafd04aa6dd2cec76049735e7fcb4e7 Mon Sep 17 00:00:00 2001 From: Kevin Yap Date: Tue, 26 Jul 2016 13:23:24 -0700 Subject: [PATCH] Add function for exporting .env file variables --- source/functions.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/functions.sh b/source/functions.sh index 1aa9b04..8cb06e1 100644 --- a/source/functions.sh +++ b/source/functions.sh @@ -8,6 +8,13 @@ function cdf() { # short for `cdfinder` cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')" } +# Exports all variables present in an .env file +function expenv() { + local envFile=${1:-".env"} + export $(cat "$envFile" | xargs) + echo "Exported variables found in \`$envFile\`" +} + # Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression function targz() { local tmpFile="${@%/}.tar" -- 2.51.2