mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
add ls-wide script
This commit is contained in:
parent
b754f10ef4
commit
e57026ec8a
1 changed files with 22 additions and 0 deletions
22
ls-wide.nu
Normal file
22
ls-wide.nu
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# A ls command that approximates the ls -sh command in bash
|
||||||
|
def ls-wide [
|
||||||
|
--columns(-c):int # The number of columns in your output
|
||||||
|
] {
|
||||||
|
let is_empty = $(= $columns | empty?)
|
||||||
|
let max_fname_size = $(ls | get name | str from | str length | math max)
|
||||||
|
let max_fsize_size = $(ls | get size | str from | str length | math max)
|
||||||
|
|
||||||
|
ls | each -n {
|
||||||
|
build-string $(echo $it.item.name | str rpad -c ' ' -l $max_fname_size) ' ' $(echo $(build-string $it.item.size) | str lpad -c ' ' -l $max_fsize_size) ' '
|
||||||
|
if $is_empty {
|
||||||
|
if $it.index mod 3 == 0 && $it.index != 0 {
|
||||||
|
echo $(char newline) | autoview
|
||||||
|
} {}
|
||||||
|
|
||||||
|
} {
|
||||||
|
if $it.index mod $columns == 0 && $it.index != 0 {
|
||||||
|
echo $(char newline) | autoview
|
||||||
|
} {}
|
||||||
|
}
|
||||||
|
} | str collect
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue