From 6a8412428b0adac25b362f1af3483cdae8bb6535 Mon Sep 17 00:00:00 2001 From: crater2150 Date: Mon, 15 Jul 2024 12:27:39 +0200 Subject: [PATCH] sv-manage: add service listing --- aliases/void | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/aliases/void b/aliases/void index 81a3fb5..434c236 100644 --- a/aliases/void +++ b/aliases/void @@ -62,19 +62,32 @@ sv() { } sv-manage() { - action=$1 - shift + local action service svdir + zparseopts -D -E d:=dir -dir:=dir + svdir=${dir[2]:-${SVDIR:-/var/service}} + if [[ -z $1 ]]; then + action=list + else + action=$1 + shift + fi case "$action" in add) for service in "$@"; do - ln -s ${SVDIR_TEMPLATES:-/etc/sv}/${service:s#/##} ${SVDIR:-/var/service} + ln -s ${SVDIR_TEMPLATES:-/etc/sv}/${service:s#/##} ${svdir} done ;; remove|rm) for service in "$@"; do - rm ${SVDIR:-/var/service}/${service:s#/##} + rm ${svdir}/${service:s#/##} done ;; + list|ls) + sv status ${svdir}/* | sed " + s@${svdir}/@@ + s@run@\x1b[1;92mrun\x1b[0m@g + s@down@\x1b[1;31mdown\x1b[0m@g + " | column -t esac }