Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: