conf2/zsh/.oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh

20 lines
312 B
Bash
Raw Permalink Normal View History

2019-01-12 15:47:23 +00:00
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