Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide env diff #1234

Merged
merged 1 commit into from Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/cmd/cmd_export.go
Expand Up @@ -100,13 +100,14 @@ func exportCommand(currentEnv Env, args []string, config *Config) (err error) {
}
}

if out := diffStatus(previousEnv.Diff(newEnv)); out != "" {
if out := diffStatus(previousEnv.Diff(newEnv)); out != "" && !config.HideEnvDiff {
logStatus(currentEnv, "export %s", out)
}

diffString := currentEnv.Diff(newEnv).ToShell(shell)
logDebug("env diff %s", diffString)
fmt.Print(diffString)

return
}

Expand Down
4 changes: 4 additions & 0 deletions internal/cmd/config.go
Expand Up @@ -23,6 +23,7 @@ type Config struct {
BashPath string
RCFile string
TomlPath string
HideEnvDiff bool
DisableStdin bool
StrictEnv bool
LoadDotenv bool
Expand Down Expand Up @@ -54,6 +55,7 @@ type tomlGlobal struct {
SkipDotenv bool `toml:"skip_dotenv"` // deprecated, use load_dotenv
LoadDotenv bool `toml:"load_dotenv"`
WarnTimeout *tomlDuration `toml:"warn_timeout"`
HideEnvDiff bool `toml:"hide_env_diff"`
}

type tomlWhitelist struct {
Expand Down Expand Up @@ -138,6 +140,8 @@ func LoadConfig(env Env) (config *Config, err error) {
return
}

config.HideEnvDiff = tomlConf.HideEnvDiff

for _, path := range tomlConf.Whitelist.Prefix {
config.WhitelistPrefix = append(config.WhitelistPrefix, expandTildePath(path))
}
Expand Down
5 changes: 5 additions & 0 deletions man/direnv.toml.1.md
Expand Up @@ -63,6 +63,11 @@ Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
This feature is disabled if the duration is lower or equal to zero.
Will be overwritten if the environment variable `DIRENV_WARN_TIMEOUT` is set to any of the above values.

### `hide_env_diff`

Set to `true` to hide the diff of the environment variables when loading the
`.envrc`. Defaults to `false`.

## [whitelist]

Specifying whitelist directives marks specific directory hierarchies or specific directories as "trusted" -- direnv will evaluate any matching .envrc files regardless of whether they have been specifically allowed. **This feature should be used with great care**, as anyone with the ability to write files to that directory (including collaborators on VCS repositories) will be able to execute arbitrary code on your computer.
Expand Down