feat(hooks): add rusty-paths.nu (#596)

This commit is contained in:
icp 2023-09-10 14:10:59 +05:30 committed by GitHub
parent 0dd97178ad
commit 51cc782344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,25 @@
# Description
#
# Include `target/debug` and `target/release` in `$env.PATH`
# while `cd`-ing into a Rust project (assumed existence of `Cargo.lock`)
#
#
# Installation
#
# 1. Move this file under any directory in `$env.NU_LIB_DIRS`
# 2. Add `source rusty-paths.nu` to `$nu.config-path`
$env.config = ($env.config | update hooks.env_change.PWD {
append {
condition: {|_, after| ($after | path join 'Cargo.lock' | path exists) }
code: {
$env.PATH = (
$env.PATH
| prepend ($env.PWD | path join 'target/debug')
| prepend ($env.PWD | path join 'target/release')
| uniq
)
}
}
})