mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
Allow relative entries in CDPATH (#216)
This allows `c` to work with relative directories like "." for the current directory or shorthand like "~/Repos" to complete from a common directory.
This commit is contained in:
parent
ed4a2de962
commit
350cf53acf
1 changed files with 2 additions and 1 deletions
|
@ -5,6 +5,7 @@ def-env c [dir = ""] {
|
||||||
$default
|
$default
|
||||||
} else {
|
} else {
|
||||||
$env.CDPATH
|
$env.CDPATH
|
||||||
|
| path expand
|
||||||
| reduce -f "" { |$it, $acc| if $acc == "" {
|
| reduce -f "" { |$it, $acc| if $acc == "" {
|
||||||
let new_path = ([$it $dir] | path join)
|
let new_path = ([$it $dir] | path join)
|
||||||
if ($new_path | path exists) {
|
if ($new_path | path exists) {
|
||||||
|
@ -21,4 +22,4 @@ def-env c [dir = ""] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# You need to have $env.CDPATH variable declared, my suggestion from config.nu:
|
# You need to have $env.CDPATH variable declared, my suggestion from config.nu:
|
||||||
# let-env CDPATH = [$env.HOME, "/", ([$env.HOME, ".config"] | path join)]
|
# let-env CDPATH = [".", $env.HOME, "/", ([$env.HOME, ".config"] | path join)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue