More efficient cdg
This commit is contained in:
parent
9ce46b5211
commit
5140316764
|
@ -1,21 +1,19 @@
|
||||||
# gclone aliases
|
# gclone aliases
|
||||||
def _gclone_dirs [] {
|
|
||||||
let slashes = ($env.GCLONE_PATH | split row "/" | length) + 3
|
|
||||||
|
|
||||||
_ls ($env.GCLONE_PATH + "/**")
|
def _gclone_dirs [] {
|
||||||
| each { $in.name }
|
_ls ($env.GCLONE_PATH + "/*")
|
||||||
| where { ($in | split row "/" | length) <= $slashes }
|
| append (_ls ($env.GCLONE_PATH + "/*/*"))
|
||||||
| each { $in | split row "/" | last }
|
| append (_ls ($env.GCLONE_PATH + "/*/*/*"))
|
||||||
|
| each { $in.name | path basename }
|
||||||
| sort
|
| sort
|
||||||
| uniq
|
| uniq
|
||||||
}
|
}
|
||||||
|
|
||||||
def --env cdg [key: string@_gclone_dirs] {
|
def --env cdg [key: string@_gclone_dirs] {
|
||||||
|
let dir = _ls ($env.GCLONE_PATH + "/*")
|
||||||
let slashes = ($env.GCLONE_PATH | split row "/" | length) + 3
|
| append (_ls ($env.GCLONE_PATH + "/*/*"))
|
||||||
|
| append (_ls ($env.GCLONE_PATH + "/*/*/*"))
|
||||||
let dir = _ls ($env.GCLONE_PATH + "/**")
|
| where { $in != null and ($in.name | path basename) == $key }
|
||||||
| where { $in != null and ($in.name | split row "/" | length) <= $slashes and ($in.name | path basename) == $key }
|
|
||||||
|
|
||||||
|
|
||||||
match ($dir | length) {
|
match ($dir | length) {
|
||||||
|
@ -38,6 +36,8 @@ def --env cdg [key: string@_gclone_dirs] {
|
||||||
(ansi reset) + " multiple entries found, please select one"
|
(ansi reset) + " multiple entries found, please select one"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
echo $dir
|
||||||
|
|
||||||
print (
|
print (
|
||||||
(ansi --escape 'A') +
|
(ansi --escape 'A') +
|
||||||
(ansi attr_bold) + "Enter your choice: " + (ansi reset)
|
(ansi attr_bold) + "Enter your choice: " + (ansi reset)
|
||||||
|
|
Loading…
Reference in New Issue