commit 746008d6e831709b12d68a68be6b73d286017bd7 parent 2c61879e1ae21017093829d798191b204f16cedf Author: Jan Pobrislo <ccx@webprojekty.cz> Date: Fri, 29 Jul 2022 00:25:55 +0200 Color-code bundles by activity Diffstat:
M | command/s | | | 25 | +++++++++++++++++++++++-- |
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/command/s b/command/s @@ -37,11 +37,31 @@ load_s6_rc() { done } +print_service_bundles() { + local b pre post s=$1 + local -a fmt_active=( '%F{yellow}%BA%b%f' '%F{cyan}I%f' '%F{magenta}-%f' ) + if ! (($+service_bundles[$s])); then + printf '\t-\n' + return + fi + for b in ${(f)service_bundles[$s]}; do + if (($+service_active[$b)); then + pre='%F{yellow}%B' + post='%b%f' + else + pre='%F{cyan}' + post='%f' + fi + printf '\t%s' "$pre$b$post" + done +} + show_oneshots() { local -a fmt_active=( '%F{yellow}%BA%b%f' '%F{cyan}I%f' ) local s for s in $oneshots; do - printf "%s %s\t%s\n" ${(%)fmt_active[${service_active[$s]:-2}]} $s ${(j: :)${(f)service_bundles[$s]:--}} + printf "%s %s" ${(%)fmt_active[${service_active[$s]:-2}]} $s + print_service_bundles $s done } @@ -62,7 +82,8 @@ show_longruns() { else active=3 fi - printf "%s %s\t%s\n" ${(%)fmt_up[$state]}${(%)fmt_active[$active]} $s ${(j: :)${(f)service_bundles[$s]:--}} + printf "%s %s\t%s\n" ${(%)fmt_up[$state]}${(%)fmt_active[$active]} $s + print_service_bundles $s done }