2016-12-14 16:49:08 +00:00
|
|
|
source_env() {
|
|
|
|
if [[ -f .env ]]; then
|
2018-08-07 22:05:34 +00:00
|
|
|
# test .env syntax
|
|
|
|
zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
|
|
|
|
|
2018-07-10 21:31:47 +00:00
|
|
|
if [[ -o a ]]; then
|
|
|
|
source .env
|
|
|
|
else
|
|
|
|
set -a
|
|
|
|
source .env
|
|
|
|
set +a
|
|
|
|
fi
|
2016-12-14 16:49:08 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
autoload -U add-zsh-hook
|
|
|
|
add-zsh-hook chpwd source_env
|
2018-08-07 21:54:07 +00:00
|
|
|
|
|
|
|
source_env
|