More efficient cdg

This commit is contained in:
Thomas Forgione 2023-11-23 19:50:26 +01:00
parent 9ce46b5211
commit 5140316764
1 changed files with 11 additions and 11 deletions

View File

@ -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)