From 79b02a45b723e9ceaf3b9897768a3c44df5c9559 Mon Sep 17 00:00:00 2001 From: ddelange <14880945+ddelange@users.noreply.github.com> Date: Thu, 20 Feb 2025 10:19:40 +0200 Subject: [PATCH] :recycle: Reverse order in .envrc --- .envrc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.envrc b/.envrc index 1262f93..ffa9a47 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,15 @@ -# first source parent directories +# ref https://direnv.net/docs/installation.html +# when direnv is installed, env vars will be automatically exported when cd'ing into a directory, and unset when cd'ing out of the directory +# brew install direnv +# install direnv hook ref https://direnv.net/docs/hook.html +# hook for bash +# cat ~/.bashrc | grep 'direnv hook' || ( echo 'eval "$(direnv hook bash)"' >> ~/.bashrc && eval "$(direnv hook bash)" ) +# hook for zsh +# cat ~/.zshrc | grep 'direnv hook' || ( echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc && eval "$(direnv hook zsh)" ) +# run once in this directory to trust this .envrc file: +# direnv allow + +# any `.envrc` files in this directory's parents will first be sourced by direnv when cd'ing into this directory source_up_if_exists -# then overwrite with current directory env vars +# write your secrets in the `.env` file (gitignore'd) - these will take presedence over env vars exported in parent directories source_env_if_exists .env