diff --git a/nushell/config/gclone.nu b/nushell/config/gclone.nu index b83a414..2393836 100644 --- a/nushell/config/gclone.nu +++ b/nushell/config/gclone.nu @@ -11,8 +11,12 @@ def _gclone_dirs [] { } def --env cdg [key: string@_gclone_dirs] { + + let slashes = ($env.GCLONE_PATH | split row "/" | length) + 3 + let dir = _ls ($env.GCLONE_PATH + "/**") - | where { ($in.name | path basename) == $key } + | where { $in != null and ($in.name | split row "/" | length) <= $slashes and ($in.name | path basename) == $key } + match ($dir | length) { 0 => { @@ -25,7 +29,7 @@ def --env cdg [key: string@_gclone_dirs] { } 1 => { - cd ($dir.name) + cd $dir.0.name } _ => { @@ -34,8 +38,6 @@ def --env cdg [key: string@_gclone_dirs] { (ansi reset) + " multiple entries found, please select one" ) - echo $dir - print ( (ansi --escape 'A') + (ansi attr_bold) + "Enter your choice: " + (ansi reset)