From a5fa00ff05509028b82ef4fe300493f5f273c8f3 Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 14 Nov 2023 11:22:11 +0100 Subject: [PATCH] Cool pueue commands --- nushell/config/aliases.nu | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/nushell/config/aliases.nu b/nushell/config/aliases.nu index 1861e2f..1f54c54 100644 --- a/nushell/config/aliases.nu +++ b/nushell/config/aliases.nu @@ -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 +}