Skip to content

Commit 2b91c23

Browse files
committed
Modify according to the zoxide configuration for Nushell.
1 parent 0beb815 commit 2b91c23

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

modules/fnm/fnm.nu

+18-14
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@ export-env {
2121
}
2222

2323
if not (which fnm | is-empty) {
24-
if (("__fnm_hooked" in $env) and ($env.__fnm_hooked | describe) == "string") {
25-
$env.__fnm_hooked = false
26-
} else {
27-
fnm-env | load-env
28-
}
24+
fnm-env | load-env
2925

30-
if (not ($env | default false __fnm_hooked | get __fnm_hooked)) {
31-
$env.__fnm_hooked = true
32-
$env.config = ($env | default {} config).config
33-
$env.config = ($env.config | default {} hooks)
34-
$env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
35-
$env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
36-
$env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append { |before, after|
26+
$env.config = (
27+
$env.config?
28+
| default {}
29+
| upsert hooks { default {} }
30+
| upsert hooks.env_change { default {} }
31+
| upsert hooks.env_change.PWD { default [] }
32+
)
33+
let __fnm_hooked = (
34+
$env.config.hooks.env_change.PWD | any { try { get __fnm_hook } catch { false } }
35+
)
36+
if not $__fnm_hooked {
37+
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
38+
__fnm_hook: true,
39+
code: {|before, after|
3740
if ('FNM_DIR' in $env) and ([.nvmrc .node-version] | path exists | any { |it| $it }) {
38-
(^fnm use); (fnm-env | load-env)
41+
(^fnm use); (fnm-env | load-env)
42+
}
3943
}
40-
}))
44+
})
4145
}
4246
}
4347
}

0 commit comments

Comments
 (0)