mirror of
https://github.com/nushell/nu_scripts.git
synced 2024-09-11 13:45:56 +03:00
feat(hooks): add rusty-paths.nu
(#596)
This commit is contained in:
parent
0dd97178ad
commit
51cc782344
25
hooks/rusty-paths/rusty-paths.nu
Normal file
25
hooks/rusty-paths/rusty-paths.nu
Normal 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
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user