From a48d63a44101e45e952468c5da3513890760eb03 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 20 Nov 2023 10:39:11 +0100 Subject: [PATCH] Fix cdg --- nushell/config/gclone.nu | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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)