mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Make Direnv Less Noisy as a Unix TIL
This commit is contained in:
32
unix/make-direnv-less-noisy.md
Normal file
32
unix/make-direnv-less-noisy.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Make Direnv Less Noisy
|
||||
|
||||
I've been using [`direnv`](https://direnv.net/) to manage project and folder
|
||||
specific environment variables for a bit now. I've found it to be pretty
|
||||
seamless. It can feel like it is littering my shell with too much output when I
|
||||
change directories though.
|
||||
|
||||
There are two levers to control its output.
|
||||
|
||||
First, the direnv logs (e.g. `direnv: loading ~/.../.envrc`) can be controlled
|
||||
with the `DIRENV_LOG_FORMAT` env var. Add this to the
|
||||
`~/.config/direnv/direnvrc` file (add that directory and file if necessary).
|
||||
You can leave it blank to altogether hide log messages or you can gray-out the
|
||||
log messages like this:
|
||||
|
||||
```
|
||||
export DIRENV_LOG_FORMAT=$'\033[2mdirenv: %s\033[0m'
|
||||
```
|
||||
|
||||
Second, you can hide the env var diff with a separate config. This diff is not
|
||||
covered under the umbrella of logs controlled by the above setting. Set
|
||||
[`hide_env_diff` in the `~/.config/direnv/direnv.toml`
|
||||
file](https://direnv.net/man/direnv.toml.1.html#codehideenvdiffcode):
|
||||
|
||||
```toml
|
||||
[global]
|
||||
hide_env_diff = true
|
||||
```
|
||||
|
||||
This second config was only added as of `v2.34.0`.
|
||||
|
||||
[source](https://esham.io/2023/10/direnv)
|
||||
Reference in New Issue
Block a user