diff --git a/cookbook/direnv.md b/cookbook/direnv.md index 9d38898d4e3..763e243fa28 100644 --- a/cookbook/direnv.md +++ b/cookbook/direnv.md @@ -17,12 +17,21 @@ To make direnv work with nushell the way it does with other shells, we can use t $env.config = { hooks: { pre_prompt: [{ || - let direnv = (direnv export json | from json) - - if not ($direnv | is-empty) { - let direnv = $direnv | upsert PATH {|it| $it.PATH | split row ":" } - $direnv | load-env - } + let direnv = (direnv export json | from json | default {}) + if ($direnv | is-empty) { + return + } + $direnv + | items {|key, value| + { + key: $key + value: (if $key in $env.ENV_CONVERSIONS { + do ($env.ENV_CONVERSIONS | get $key | get from_string) $value + } else { + $value + }) + } + } | transpose -ird | load-env }] } }