From 227877d5ec504c8667b8a0189f3d33b6420541f7 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Mon, 11 Mar 2024 15:19:39 +0100 Subject: [PATCH] Update nushell --- config/aliases.nu | 6 +++--- config/gclone.nu | 17 +++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/config/aliases.nu b/config/aliases.nu index cf84a83..7caecb0 100644 --- a/config/aliases.nu +++ b/config/aliases.nu @@ -34,13 +34,13 @@ def _ls_format_mode [mode: string] { # quick and easy ls def ls [dir?: string] { - let output = (if $dir == null { _ls } else { _ls $dir }) | sort-by type name -i + let output = (if $dir == null { _ls } else { _ls (glob $dir) }) | sort-by type name -i if ($output | length) == 0 { "" | cat } else { $output | grid -c -s " " | cat } } # ls with hidden files def la [dir?: string] { - (if $dir == null { _ls -al } else { _ls -al $dir }) + (if $dir == null { _ls -al } else { _ls -al (glob $dir) }) | sort-by type name -i | each { $in | update mode (_ls_format_mode $in.mode) } | select mode name target user size modified @@ -48,7 +48,7 @@ def la [dir?: string] { # ls with details def ll [dir?: string] { - (if $dir == null { _ls -l } else { _ls -l }) + (if $dir == null { _ls -l } else { _ls -l (glob $dir) }) | each { $in | update mode (_ls_format_mode $in.mode) } | sort-by type name -i | select mode name target user size modified diff --git a/config/gclone.nu b/config/gclone.nu index 9d91422..9271052 100644 --- a/config/gclone.nu +++ b/config/gclone.nu @@ -1,20 +1,13 @@ # gclone aliases def _gclone_dirs [] { - _ls ($env.GCLONE_PATH + "/*") - | append (_ls ($env.GCLONE_PATH + "/*/*")) - | append (_ls ($env.GCLONE_PATH + "/*/*/*")) - | each { $in.name | path basename } - | sort - | uniq + glob ($env.GCLONE_PATH + "/**") -d 3 | sort | uniq } # cd to a git directory def --env cdg [key: string@_gclone_dirs] { - 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 } + let dir = glob ($env.GCLONE_PATH + "/**") -d 3 + | where { $in != null and ($in | path basename) == $key } match ($dir | length) { @@ -28,7 +21,7 @@ def --env cdg [key: string@_gclone_dirs] { } 1 => { - cd $dir.0.name + cd $dir.0 } _ => { @@ -66,7 +59,7 @@ def --env cdg [key: string@_gclone_dirs] { return } - cd ($dir | get $choice | get name) + cd ($dir | get $choice) } } }