Stop direnv showing all environment variables on load

2.1k Views Asked by At

I have direnv installed, and I was wondering if there was a way of stopping it from showing all of the environment variables it loads? The output lines it currently shows are:

direnv: loading .envrc
direnv: export +FOO +BAR +FOO2 +BAR2 +FOO3 +BAR3 +FOO4 +BAR4

I'm fine with having the first line show, but since my second line has something like 50 variables in it, it's slightly annoying to have the lot of them shown every time I go into the directory.

2

There are 2 best solutions below

0
On

As far as I know, you cannot change that behavior through configuration.

If that behavior was part of the stdlib, you could override it. In fact, the first ouput, direnv: loading .envrc comes from source_env which uses log_status to output to stderr, so you could override either of source_env or log_status in ~/.config/direnv/.direnvrc or ~/.direnvrc.

However, the second output is coming from diffString in cmd_export.go (via log_status in log.go). Short of compiling your own, modified version of direnv, I don't see how you can change that behavior as of the current release (v2.17.0).

1
On

It's possible to remove the logs entirely by setting export DIRENV_LOG_FORMAT= but then the rest of the logs are also missing