Skip to content

Commit 6acb2d9

Browse files
Fix direnv not using transformed values (#960)
* Simplify direnv default value * Set 4 spaces indent * Transform direnv values using $env.ENV_CONVERSIONS * Simplify env filtering * Simplify direnv env convert pipeline
1 parent 8bd0613 commit 6acb2d9

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

cookbook/direnv.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,21 @@ To make direnv work with nushell the way it does with other shells, we can use t
1717
$env.config = {
1818
hooks: {
1919
pre_prompt: [{ ||
20-
let direnv = (direnv export json | from json)
21-
22-
if not ($direnv | is-empty) {
23-
let direnv = $direnv | upsert PATH {|it| $it.PATH | split row ":" }
24-
$direnv | load-env
25-
}
20+
let direnv = (direnv export json | from json | default {})
21+
if ($direnv | is-empty) {
22+
return
23+
}
24+
$direnv
25+
| items {|key, value|
26+
{
27+
key: $key
28+
value: (if $key in $env.ENV_CONVERSIONS {
29+
do ($env.ENV_CONVERSIONS | get $key | get from_string) $value
30+
} else {
31+
$value
32+
})
33+
}
34+
} | transpose -ird | load-env
2635
}]
2736
}
2837
}

0 commit comments

Comments
 (0)