mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-05 01:46:46 +01:00
dotenv: add support for custom env file names (#7861)
This commit is contained in:
parent
5f7666e20b
commit
f960e2be6f
2 changed files with 19 additions and 4 deletions
|
|
@ -1,13 +1,13 @@
|
|||
source_env() {
|
||||
if [[ -f .env ]]; then
|
||||
if [[ -f $ZSH_DOTENV_FILE ]]; then
|
||||
# test .env syntax
|
||||
zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
|
||||
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
|
||||
|
||||
if [[ -o a ]]; then
|
||||
source .env
|
||||
source $ZSH_DOTENV_FILE
|
||||
else
|
||||
set -a
|
||||
source .env
|
||||
source $ZSH_DOTENV_FILE
|
||||
set +a
|
||||
fi
|
||||
fi
|
||||
|
|
@ -16,4 +16,8 @@ source_env() {
|
|||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd source_env
|
||||
|
||||
if [[ -z $ZSH_DOTENV_FILE ]]; then
|
||||
ZSH_DOTENV_FILE=.env
|
||||
fi
|
||||
|
||||
source_env
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue