mostly improvements, wip
[distro-setup] / brc
diff --git a/brc b/brc
index 32a2c66212893c101c8e7c57670f5486a6f613c8..8e1b3276f0358ac96cd038e9764c700e811a497e 100644 (file)
--- a/brc
+++ b/brc
@@ -689,10 +689,10 @@ jdo() {
   fi
   # -q = quiet
   journalctl -qn2 -f -u "$cmd_name" &
+  jr_pid=$!
   # Trial and error of time needed to avoid missing initial lines.
   # .5 was not reliable. 1 was not reliable. 2 was not reliable
   sleep 4
-  jr_pid=$!
   systemd-run --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$?
   # The sleep lets the journal output its last line
   # before the prompt comes up.
@@ -2450,6 +2450,19 @@ serstat() {
   systemctl -n 40 status "$@"
 }
 
+# assume last arg is a service and we want to tail its log.
+serj() {
+  local service jr_pid ret
+  ret=0
+  service="${*: -1}"
+  journalctl -qn2 -f -u "$service" &
+  sleep 3
+  s systemctl "$@" || ret=$?
+  sleep .5
+  kill %%
+  (( ret == 0 )) || return $ret
+}
+
 seru() { systemctl --user "$@"; }
 # like restart, but do nothing if its not already started
 srestart() {