From 55457187d18221e76bd12f0fb2cfab65c49b92fb Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 5 Mar 2019 01:09:01 +0100 Subject: Initial commit --- .oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh (limited to '.oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh') diff --git a/.oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh b/.oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh new file mode 100644 index 0000000..b701b55 --- /dev/null +++ b/.oh-my-zsh/plugins/dotenv/dotenv.plugin.zsh @@ -0,0 +1,19 @@ +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 -- cgit v1.2.3