You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
312 B
20 lines
312 B
6 years ago
|
source_env() {
|
||
|
if [[ -f .env ]]; then
|
||
|
# test .env syntax
|
||
|
zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
|
||
|
|
||
|
if [[ -o a ]]; then
|
||
|
source .env
|
||
|
else
|
||
|
set -a
|
||
|
source .env
|
||
|
set +a
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
autoload -U add-zsh-hook
|
||
|
add-zsh-hook chpwd source_env
|
||
|
|
||
|
source_env
|