This looks good and neater than my solution in my .zshrc:
envup() {
local file=$([ -z "$1" ] && echo ".env" || echo ".env.$1")
if [ -f $file ]; then
set -a
source $file
set +a
else
echo "No $file file found" 1>&2
return 1
fi
}
You can also specify `envup development` to load .env.development files should you want. Obviously this will pollute the current shell but for me it is fine.
envup() {
}You can also specify `envup development` to load .env.development files should you want. Obviously this will pollute the current shell but for me it is fine.