Diff
1diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md
2index e880e9d6974fdacfc30587d25fccfdc794f8c2d2..cac552485ffcf1cc7884223d9b132bf4d45523b4 100644
3--- a/plugins/dotenv/README.md
4+++ b/plugins/dotenv/README.md
5@@ -32,6 +32,17 @@ PORT=3001
6 ```
7 You can even mix both formats, although it's probably a bad idea.
8
9+### ZSH_DOTENV_FILE
10+
11+You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
12+If the variable isn't set, the plugin will default to use `.env`.
13+For example, this will make the plugin look for files named `.dotenv` and load them:
14+
15+```
16+# in ~/.zshrc, before Oh My Zsh is sourced:
17+ZSH_DOTENV_FILE=.dotenv
18+```
19+
20 ## Version Control
21
22 **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.
23diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh
24index b701b5596c8ba79eb1f0001af80035899dbbf347..89763d0ee37ac03b98eaf3412f6e965700fadbc4 100644
25--- a/plugins/dotenv/dotenv.plugin.zsh
26+++ b/plugins/dotenv/dotenv.plugin.zsh
27@@ -1,13 +1,13 @@
28 source_env() {
29- if [[ -f .env ]]; then
30+ if [[ -f $ZSH_DOTENV_FILE ]]; then
31 # test .env syntax
32- zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
33+ zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
34
35 if [[ -o a ]]; then
36- source .env
37+ source $ZSH_DOTENV_FILE
38 else
39 set -a
40- source .env
41+ source $ZSH_DOTENV_FILE
42 set +a
43 fi
44 fi
45@@ -16,4 +16,8 @@ source_env() {
46 autoload -U add-zsh-hook
47 add-zsh-hook chpwd source_env
48
49+if [[ -z $ZSH_DOTENV_FILE ]]; then
50+ ZSH_DOTENV_FILE=.env
51+fi
52+
53 source_env