diff --git a/nu-hooks/nu-hooks/rusty-paths/rusty-paths.nu b/nu-hooks/nu-hooks/rusty-paths/rusty-paths.nu index 863dc96..a7cbecb 100644 --- a/nu-hooks/nu-hooks/rusty-paths/rusty-paths.nu +++ b/nu-hooks/nu-hooks/rusty-paths/rusty-paths.nu @@ -13,13 +13,24 @@ $env.config = ($env.config | upsert hooks.env_change.PWD { append { condition: {|_, after| ($after | path join 'Cargo.lock' | path exists) } - code: { + code: {|_, after| $env.PATH = ( $env.PATH - | prepend ($env.PWD | path join 'target' 'debug') - | prepend ($env.PWD | path join 'target' 'release') + | prepend ($after | path join 'target' 'debug') + | prepend ($after | path join 'target' 'release') | uniq - ) + ) + } + } + | append { + condition: {|before, _| ($before | default '' | path join 'Cargo.lock' | path exists) } + code: {|before, _| + $env.PATH = ( + $env.PATH + | where $it != ($before | path join 'target' 'debug') + | where $it != ($before | path join 'target' 'release') + | uniq + ) } } })