summaryrefslogtreecommitdiff
path: root/plugins/dotenv
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/dotenv')
-rw-r--r--plugins/dotenv/README.md19
-rw-r--r--plugins/dotenv/dotenv.plugin.zsh8
2 files changed, 22 insertions, 5 deletions
diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
index ade09fbb2..e0e75571f 100644
--- a/plugins/dotenv/README.md
+++ b/plugins/dotenv/README.md
@@ -2,19 +2,19 @@
Automatically load your project ENV variables from `.env` file when you `cd` into project root directory.
-Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
+Storing configuration in the environment is one of the tenets of a [twelve-factor app](http://www.12factor.net). Anything that is likely to change between deployment environments, such as resource handles for databases or credentials for external services, should be extracted from the code into environment variables.
## Installation
Just add the plugin to your `.zshrc`:
```sh
-plugins=(git man dotenv)
+plugins=(... dotenv)
```
## Usage
-Create `.env` file inside your project directory and put your local ENV variables there.
+Create `.env` file inside your project root directory and put your ENV variables there.
For example:
```sh
@@ -30,5 +30,16 @@ SECRET_KEY=7c6c72d959416d5aa368a409362ec6e2ac90d7f
MONGO_URI=mongodb://127.0.0.1:27017
PORT=3001
```
+You can even mix both formats, although it's probably a bad idea.
-**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it supposed to be local only.
+## Version Control
+
+**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only.
+
+## Disclaimer
+
+This plugin only sources the `.env` file. Nothing less, nothing more. It doesn't do any checks. It's designed to be the fastest and simplest option. You're responsible for the `.env` file content. You can put some code (or weird symbols) there, but do it on your own risk. `dotenv` is the basic tool, yet it does the job.
+
+If you need more advanced and feature-rich ENV management, check out these awesome projects:
+* [direnv](https://github.com/direnv/direnv)
+* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv)
diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
index 9dd784229..fa47c4c68 100644
--- a/plugins/dotenv/dotenv.plugin.zsh
+++ b/plugins/dotenv/dotenv.plugin.zsh
@@ -2,7 +2,13 @@
source_env() {
if [[ -f .env ]]; then
- source .env
+ if [[ -o a ]]; then
+ source .env
+ else
+ set -a
+ source .env
+ set +a
+ fi
fi
}