diff --git a/nushell/config/gclone.nu b/nushell/config/gclone.nu index 2393836..ed3c609 100644 --- a/nushell/config/gclone.nu +++ b/nushell/config/gclone.nu @@ -1,21 +1,19 @@ # gclone aliases -def _gclone_dirs [] { - let slashes = ($env.GCLONE_PATH | split row "/" | length) + 3 - _ls ($env.GCLONE_PATH + "/**") - | each { $in.name } - | where { ($in | split row "/" | length) <= $slashes } - | each { $in | split row "/" | last } +def _gclone_dirs [] { + _ls ($env.GCLONE_PATH + "/*") + | append (_ls ($env.GCLONE_PATH + "/*/*")) + | append (_ls ($env.GCLONE_PATH + "/*/*/*")) + | each { $in.name | path basename } | sort | uniq } def --env cdg [key: string@_gclone_dirs] { - - let slashes = ($env.GCLONE_PATH | split row "/" | length) + 3 - - let dir = _ls ($env.GCLONE_PATH + "/**") - | where { $in != null and ($in.name | split row "/" | length) <= $slashes and ($in.name | path basename) == $key } + let dir = _ls ($env.GCLONE_PATH + "/*") + | append (_ls ($env.GCLONE_PATH + "/*/*")) + | append (_ls ($env.GCLONE_PATH + "/*/*/*")) + | where { $in != null and ($in.name | path basename) == $key } match ($dir | length) { @@ -38,6 +36,8 @@ 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)