Skip to content

Commit c20d19b

Browse files
committed
Add Tell direnv To Load The Env File as a Unix TIL
1 parent 8394d5b commit c20d19b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1387 TILs and counting..._
13+
_1388 TILs and counting..._
1414

1515
---
1616

@@ -1406,6 +1406,7 @@ _1387 TILs and counting..._
14061406
- [Specify The Language For A File With Bat](unix/specify-the-language-for-a-file-with-bat.md)
14071407
- [Sort In Numerical Order](unix/sort-in-numerical-order.md)
14081408
- [Switch Versions of a Brew Formula](unix/switch-versions-of-a-brew-formula.md)
1409+
- [Tell direnv To Load The Env File](unix/tell-direnv-to-load-the-env-file.md)
14091410
- [Touch Access And Modify Times Individually](unix/touch-access-and-modify-times-individually.md)
14101411
- [Undo Some Command Line Editing](unix/undo-some-command-line-editing.md)
14111412
- [Update Package Versions Known By asdf Plugin](unix/update-package-versions-known-by-asdf-plugin.md)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Tell direnv To Load The Env File
2+
3+
By default [`direnv`](https://direnv.net/) looks for and evaluates the `.envrc`
4+
file that appears in a given project directory. This default behavior is good
5+
for things like setting certain path dependencies (e.g. a specific version of
6+
node or postgres).
7+
8+
To the end of using `direnv` to set up the development environment, it can be
9+
useful to have it also load the `.env` file into the current shell's
10+
environment.
11+
12+
To get `direnv` to do that, add this line to the `.envrc` file:
13+
14+
```
15+
dotenv_if_exists .env
16+
```
17+
18+
This specific loads all the environment variables in `.env`. If there are other
19+
files, such as `.env.development` that need to be loaded in, those can be
20+
included with additional
21+
[`dotenv_if_exists`](https://direnv.net/man/direnv-stdlib.1.html#codedotenvifexists-ltdotenvpathgtcode)
22+
declarations.

0 commit comments

Comments
 (0)