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

View File

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