8d35fa0e2f32dab6894ca06bfc333af94be97ec7

Author
Arthur <mardybm@gmail.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

add dotenv plugin (#4373)

Diff

This diff is truncated to protect this page.

 1diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..ade09fbb20d4dbada9a9363c70666ce507bdd39e
 4--- /dev/null
 5+++ b/plugins/dotenv/README.md
 6@@ -0,0 +1,34 @@
 7+# dotenv
 8+
 9+Automatically load your project ENV variables from `.env` file when you `cd` into project root directory.
10+
11diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
12new file mode 100644
13index 0000000000000000000000000000000000000000..9dd7842293c4a28b4a8d06a012a0204bf325b660
14--- /dev/null
15+++ b/plugins/dotenv/dotenv.plugin.zsh
16@@ -0,0 +1,10 @@
17+#!/bin/zsh
18+
19+source_env() {
20+  if [[ -f .env ]]; then
21+    source .env
22+  fi
23+}
24+
25+autoload -U add-zsh-hook
26+add-zsh-hook chpwd source_env