This commit is contained in:
Thomas Forgione 2023-11-13 09:44:39 +01:00
parent 647d00c8eb
commit eefa96bb9a
1 changed files with 21 additions and 87 deletions

View File

@ -17,103 +17,36 @@ $env.config.history.file_format = "sqlite"
$env.config.filesize.metric = false $env.config.filesize.metric = false
$env.config.table.mode = light $env.config.table.mode = light
# remove extension shortcut
def rm-ext [] {
$in | path parse | udpate extension "" | get parent stem | str join "/"
}
# ls aliases # ls aliases
alias _ls = ls alias _ls = 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" { let w1 = if ($chars | get 1) == "w" { [(ansi red_bold), "w", (ansi reset)] } else { [(ansi grey), "-"] }
[(ansi yellow_bold), "r", (ansi reset)] let x1 = if ($chars | get 2) == "x" { [(ansi green_bold), "x", (ansi reset)] } else { [(ansi grey), "-"] }
} else { let r2 = if ($chars | get 3) == "r" { [(ansi yellow), "r", (ansi reset)] } else { [(ansi grey), "-"] }
[(ansi grey), "-"] let w2 = if ($chars | get 4) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] }
} | str join) let x2 = if ($chars | get 5) == "x" { [(ansi green), "x"] } else { [(ansi grey), "-"] }
let r3 = if ($chars | get 6) == "r" { [(ansi yellow), "r", (ansi reset)] } else { [(ansi grey), "-"] }
let w1 = (if ($chars | get 1) == "w" { let w3 = if ($chars | get 7) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] }
[(ansi red_bold), "w", (ansi reset)] let x3 = if ($chars | get 8) == "x" { [(ansi green), "x"] } else { [(ansi grey), "-"] }
} else { [$r1, $w1, $x1, $r2, $w2, $x2, $r3, $w3, $x3] | each { $in | str join } | str join
[(ansi grey), "-"]
} | str join)
let x1 = (if ($chars | get 2) == "x" {
[(ansi green_bold), "x", (ansi reset)]
} else {
[(ansi grey), "-"]
} | str join)
let r2 = (if ($chars | get 3) == "r" {
[(ansi yellow), "r", (ansi reset)]
} else {
[(ansi grey), "-"]
} | str join)
let w2 = (if ($chars | get 4) == "w" {
[(ansi red), "w"]
} else {
[(ansi grey), "-"]
} | str join)
let x2 = (if ($chars | get 5) == "x" {
[(ansi green), "x"]
} else {
[(ansi grey), "-"]
} | str join)
let r3 = (if ($chars | get 6) == "r" {
[(ansi yellow), "r", (ansi reset)]
} else {
[(ansi grey), "-"]
} | str join)
let w3 = (if ($chars | get 7) == "w" {
[(ansi red), "w"]
} else {
[(ansi grey), "-"]
} | str join)
let x3 = (if ($chars | get 8) == "x" {
[(ansi green), "x"]
} else {
[(ansi grey), "-"]
} | str join)
[
$r1
$w1
$x1
$r2
$w2
$x2
$r3
$w3
$x3
] | str join
} }
def l [dir?: string] { def l [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i
| 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
}
} }
def ls [dir?: string] { def ls [dir?: string] {
let output = _ls (if $dir == null { "" } else { $dir }) let output = _ls (if $dir == null { "" } else { $dir }) | sort-by type name -i
| 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
}
} }
def la [dir?: string] { def la [dir?: string] {
@ -133,7 +66,8 @@ def ll [dir?: string] {
# cool du (don't display everything) # cool du (don't display everything)
alias _du = du alias _du = du
def du [...args] { def du [...args] {
$args | each { _du $in } | select path apparent physical let parsed_args = if ($args | is-empty) { ["*"] } else { $args }
$parsed_args | each { _du -a $in | select path apparent physical } | flatten
} }
# cool df # cool df