l for _ls

This commit is contained in:
Thomas Forgione 2023-12-13 10:27:57 +01:00
parent 94c74310b1
commit d961e63c83
1 changed files with 3 additions and 6 deletions

View File

@ -15,6 +15,9 @@ def rm-ext [] {
# ls builtin # ls builtin
alias _ls = ls alias _ls = ls
# shortcut for ls builtin
alias l = _ls
def _ls_format_mode [mode: string] { def _ls_format_mode [mode: string] {
let chars = $mode | split chars let chars = $mode | split chars
let r1 = if ($chars | get 0) == "r" { [(ansi yellow_bold), "r", (ansi reset)] } else { [(ansi grey), "-"] } let r1 = if ($chars | get 0) == "r" { [(ansi yellow_bold), "r", (ansi reset)] } else { [(ansi grey), "-"] }
@ -29,12 +32,6 @@ def _ls_format_mode [mode: string] {
[$r1, $w1, $x1, $r2, $w2, $x2, $r3, $w3, $x3] | each { $in | str join } | str join [$r1, $w1, $x1, $r2, $w2, $x2, $r3, $w3, $x3] | each { $in | str join } | str join
} }
# quick and easy ls
def l [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i
if ($output | length) == 0 { "" | cat } else { $output | grid -c -s " " | cat }
}
# quick and easy ls # quick and easy ls
def ls [dir?: string] { def ls [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i