Permanently exporting environment variables using direnv (Linux)

Permanently exporting environment variables using direnv (Linux)

PROBLEM: I use some variables (credentials) so often, but I don’t like exporting them each time
SOLUTION: Start using direnv!

Direnv should be already present in your system

You can check the same on the direnv website (here), if is not, you can always build it from binary.

Hook direnv into shell

Add this line on the end of your .bashrc file (if you are using bash)

Create .envrc file

And put all variables you would like to have accesible in this (and child) folder(s):

Allow direnv

Just run this command inside the dir where you created .envrc file

And whenever you enter this dir you should see:

and also whenever you leave

Full docs: direnv.net

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments