Update nushell

This commit is contained in:
Thomas Forgione 2024-03-11 15:19:39 +01:00
parent 60c083cafb
commit 227877d5ec
2 changed files with 8 additions and 15 deletions

View File

@ -34,13 +34,13 @@ def _ls_format_mode [mode: string] {
# quick and easy ls # quick and easy ls
def ls [dir?: string] { 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 } if ($output | length) == 0 { "" | cat } else { $output | grid -c -s " " | cat }
} }
# ls with hidden files # ls with hidden files
def la [dir?: string] { 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 | sort-by type name -i
| each { $in | update mode (_ls_format_mode $in.mode) } | each { $in | update mode (_ls_format_mode $in.mode) }
| select mode name target user size modified | select mode name target user size modified
@ -48,7 +48,7 @@ def la [dir?: string] {
# ls with details # ls with details
def ll [dir?: string] { 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) } | each { $in | update mode (_ls_format_mode $in.mode) }
| sort-by type name -i | sort-by type name -i
| select mode name target user size modified | select mode name target user size modified

View File

@ -1,20 +1,13 @@
# gclone aliases # gclone aliases
def _gclone_dirs [] { def _gclone_dirs [] {
_ls ($env.GCLONE_PATH + "/*") glob ($env.GCLONE_PATH + "/**") -d 3 | sort | uniq
| append (_ls ($env.GCLONE_PATH + "/*/*"))
| append (_ls ($env.GCLONE_PATH + "/*/*/*"))
| each { $in.name | path basename }
| sort
| uniq
} }
# cd to a git directory # cd to a git directory
def --env cdg [key: string@_gclone_dirs] { def --env cdg [key: string@_gclone_dirs] {
let dir = _ls ($env.GCLONE_PATH + "/*") let dir = glob ($env.GCLONE_PATH + "/**") -d 3
| append (_ls ($env.GCLONE_PATH + "/*/*")) | where { $in != null and ($in | path basename) == $key }
| append (_ls ($env.GCLONE_PATH + "/*/*/*"))
| where { $in != null and ($in.name | path basename) == $key }
match ($dir | length) { match ($dir | length) {
@ -28,7 +21,7 @@ def --env cdg [key: string@_gclone_dirs] {
} }
1 => { 1 => {
cd $dir.0.name cd $dir.0
} }
_ => { _ => {
@ -66,7 +59,7 @@ def --env cdg [key: string@_gclone_dirs] {
return return
} }
cd ($dir | get $choice | get name) cd ($dir | get $choice)
} }
} }
} }