2023-11-14 11:22:11 +01:00
|
|
|
# tildize
|
|
|
|
def tildize [] {
|
|
|
|
if ($in | path split | zip ($env.HOME | path split) | all { $in.0 == $in.1 }) {
|
|
|
|
($in | str replace $env.HOME "~")
|
|
|
|
} else {
|
|
|
|
$in
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-13 10:59:32 +01:00
|
|
|
# remove extension shortcut
|
|
|
|
def rm-ext [] {
|
|
|
|
$in | path parse | udpate extension "" | get parent stem | str join "/"
|
|
|
|
}
|
|
|
|
|
|
|
|
# ls aliases
|
|
|
|
alias _ls = ls
|
|
|
|
|
|
|
|
def _ls_format_mode [mode: string] {
|
|
|
|
let chars = $mode | split chars
|
|
|
|
let r1 = if ($chars | get 0) == "r" { [(ansi yellow_bold), "r", (ansi reset)] } else { [(ansi grey), "-"] }
|
|
|
|
let w1 = if ($chars | get 1) == "w" { [(ansi red_bold), "w", (ansi reset)] } else { [(ansi grey), "-"] }
|
|
|
|
let x1 = if ($chars | get 2) == "x" { [(ansi green_bold), "x", (ansi reset)] } else { [(ansi grey), "-"] }
|
|
|
|
let r2 = if ($chars | get 3) == "r" { [(ansi yellow), "r", (ansi reset)] } else { [(ansi grey), "-"] }
|
|
|
|
let w2 = if ($chars | get 4) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] }
|
|
|
|
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 w3 = if ($chars | get 7) == "w" { [(ansi red), "w"] } else { [(ansi grey), "-"] }
|
|
|
|
let x3 = if ($chars | get 8) == "x" { [(ansi green), "x"] } else { [(ansi grey), "-"] }
|
|
|
|
[$r1, $w1, $x1, $r2, $w2, $x2, $r3, $w3, $x3] | each { $in | str join } | str join
|
|
|
|
}
|
|
|
|
|
|
|
|
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 }
|
|
|
|
}
|
|
|
|
|
|
|
|
def ls [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 }
|
|
|
|
}
|
|
|
|
|
|
|
|
def la [dir?: string] {
|
|
|
|
_ls -al (if $dir == null { "" } else { $dir })
|
|
|
|
| sort-by type name -i
|
|
|
|
| each { $in | update mode (_ls_format_mode $in.mode) }
|
|
|
|
| select mode name target user size modified
|
|
|
|
}
|
|
|
|
|
|
|
|
def ll [dir?: string] {
|
|
|
|
_ls -l (if $dir == null { "" } else { $dir })
|
|
|
|
| each { $in | update mode (_ls_format_mode $in.mode) }
|
|
|
|
| sort-by type name -i
|
|
|
|
| select mode name target user size modified
|
|
|
|
}
|
|
|
|
|
|
|
|
# cool du (don't display everything)
|
|
|
|
alias _du = du
|
|
|
|
def du [...args] {
|
|
|
|
let parsed_args = if ($args | is-empty) { ["*"] } else { $args }
|
|
|
|
$parsed_args | each { _du -a $in | select path apparent physical } | flatten
|
|
|
|
}
|
|
|
|
|
|
|
|
# cool df
|
|
|
|
def df [] {
|
|
|
|
^df -h
|
|
|
|
| str replace "Sys. de fichiers" "@"
|
|
|
|
| str replace "Monté sur" "@"
|
|
|
|
| detect columns
|
2023-11-15 14:13:50 +01:00
|
|
|
| rename "filesystem" "size" "used" "available" "used%" "mountpoint"
|
2023-11-13 10:59:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
# easy markdown formamtter
|
|
|
|
def to-md [] {
|
|
|
|
let arg = $in
|
|
|
|
$env.config.table.mode = markdown;
|
|
|
|
echo $arg
|
|
|
|
}
|
|
|
|
|
|
|
|
# Useful aliases
|
2023-11-16 10:18:15 +01:00
|
|
|
alias ip = ip -c
|
2023-11-13 10:59:32 +01:00
|
|
|
alias v = nvim
|
|
|
|
alias :q = exit
|
2023-11-14 10:38:28 +01:00
|
|
|
alias pdf = pueue add evince
|
2023-11-13 10:59:32 +01:00
|
|
|
alias rg = rg -uu
|
|
|
|
def-env mkcd [dir: string] { mkdir $dir; cd $dir }
|
2023-11-14 11:22:11 +01:00
|
|
|
alias pa = pueue add --immediate
|
|
|
|
def pst [] {
|
|
|
|
pueue status -j
|
|
|
|
| from json
|
|
|
|
| get tasks
|
|
|
|
| transpose
|
|
|
|
| each { $in | get column1 }
|
|
|
|
| each {
|
|
|
|
let stdin = $in
|
|
|
|
|
|
|
|
$stdin | update status (
|
|
|
|
if $stdin.status == "Running" {
|
|
|
|
((ansi yellow) + "Running")
|
|
|
|
} else if not (echo $stdin.status | get -i Done | is-empty) {
|
|
|
|
let exit_value = $stdin.status | get "Done"
|
|
|
|
|
|
|
|
if ($exit_value == "Success") {
|
|
|
|
((ansi green) + "Success")
|
|
|
|
} else {
|
|
|
|
(ansi red) + "Failed (" + ($exit_value | get "Failed" | into string) + ")"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
"Unknown???"
|
|
|
|
}
|
|
|
|
)
|
|
|
|
| update path ($in.path | tildize)
|
|
|
|
| update start ((ansi magenta) + ($in.start | date humanize))
|
|
|
|
| update end ((ansi magenta) + ($in.end | date humanize))
|
|
|
|
}
|
|
|
|
| select status command path start end
|
|
|
|
}
|