diff --git a/site-modules/core/files/nushell/config.nu b/site-modules/core/files/nushell/config.nu index 82e6426..0e04d0d 100644 --- a/site-modules/core/files/nushell/config.nu +++ b/site-modules/core/files/nushell/config.nu @@ -1,4 +1,4 @@ -use path.nu +use path.nu * use fzf.nu * use neovim.nu * @@ -16,6 +16,7 @@ $env.config = { PWD: [ {|_, after| nvm dir-hook $after } {|_, after| rvm-dir-hook $after } + {|_, after| node-modules-dir-hook $after } ] } } diff --git a/site-modules/core/files/nushell/scripts/path.nu b/site-modules/core/files/nushell/scripts/path.nu index 142f854..9aed057 100644 --- a/site-modules/core/files/nushell/scripts/path.nu +++ b/site-modules/core/files/nushell/scripts/path.nu @@ -6,3 +6,15 @@ export-env { | prepend ([$env.HOME ".cargo" "bin"] | path join) | str join ":" } + +export def --env node-modules-dir-hook [dir: string] { + let nodePath = ([$dir, "node_modules", ".bin"] | path join) + if ($nodePath | path exists) { + $env.PATH = $env.PATH + | split row ":" + | where {|x| not ($x | str contains "node_modules")} + | prepend $nodePath + | str join ":" + } +} +