1
Fork 0
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:
Eric Hodel 2022-05-12 13:46:42 -07:00 committed by GitHub
parent ed4a2de962
commit 350cf53acf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ def-env c [dir = ""] {
$default
} else {
$env.CDPATH
| path expand
| reduce -f "" { |$it, $acc| if $acc == "" {
let new_path = ([$it $dir] | path join)
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:
# let-env CDPATH = [$env.HOME, "/", ([$env.HOME, ".config"] | path join)]
# let-env CDPATH = [".", $env.HOME, "/", ([$env.HOME, ".config"] | path join)]