The direnv is package which only use to set environment values in any directory.
When you use 'cd' command for running in some project.
It will set environment values.
For example,
cd Desktop/moritakenji/
morita-no-MacBook-Pro :: Desktop/moritakenji/ » echo ${NAME} <-run
(print is empty) <-console
cd Desktop/moritakenji/sandbox
direnv: loading .envrc <-console
direnv: export +NAME <-console
morita-no-MacBook-Pro :: Desktop/moritakenji/sandbox » echo ${NAME} <-run
morita <- console
brew install direnv
in this case zhrc
# reading direnv
eval "$(direnv hook zsh)"
don't forget to update it with source
if you using bash now, replace zsh to bash
set environment values as NAME, the value is morita
Notice that it is not srounded some single qute.
export NAME=morita
direnv: loading .envrc
direnv: export +NAME
you can see setting it
and then, try to print NAME
echo ${NAME}
morita
if an error occures like some fllowing.
direnv: error .envrc is blocked. Run `direnv allow` to approve its content.
run $ direnv allow
thank you
3rd result on google, thanks ☕