Cool pueue commands

This commit is contained in:
Thomas Forgione 2023-11-14 11:22:11 +01:00
parent 83197645fc
commit a5fa00ff05
1 changed files with 40 additions and 0 deletions

View File

@ -1,3 +1,12 @@
# tildize
def tildize [] {
if ($in | path split | zip ($env.HOME | path split) | all { $in.0 == $in.1 }) {
($in | str replace $env.HOME "~")
} else {
$in
}
}
# remove extension shortcut
def rm-ext [] {
$in | path parse | udpate extension "" | get parent stem | str join "/"
@ -73,3 +82,34 @@ alias :q = exit
alias pdf = pueue add evince
alias rg = rg -uu
def-env mkcd [dir: string] { mkdir $dir; cd $dir }
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
}