mostly fixes
[distro-setup] / brc
diff --git a/brc b/brc
index 6322eb97c22063be93d93b6feb0f0969ef24e668..02ad1a67b78073f1cb58f6bac878d3e64def4582 100644 (file)
--- a/brc
+++ b/brc
@@ -466,6 +466,10 @@ c() {
 }
 ccomp cd c
 
+bwm() {
+  s bwm-ng -T avg -d
+}
+
 b() {
   local topb
   if (( ${#_iankdirb[@]} == 0 )); then
@@ -940,14 +944,18 @@ eless() {
 }
 ccomp less eless
 eqcat() {
-  exiqgrep -i -o 60 | while read -r i; do
+  exiqgrep -ir.\* -o 60 | while read -r i; do
     hlm exim -Mvc $i
     echo
     hlm exigrep $i /var/log/exim4/mainlog | cat ||:
   done
 }
 eqrmf() {
-  exiqgrep -i | xargs exim -Mrm
+  # other ways to get the list of message ids:
+  # exim -bp | awk 'NF == 4 {print $3}'
+  # # this is slower 160ms, vs 60.
+  # exipick -i
+  exiqgrep -ir.\* | xargs exim -Mrm
 }
 
 econfdevnew() {
@@ -1399,7 +1407,15 @@ nags() {
 }
 
 nmt() {
-  s nmtui-connect "$@"
+  # cant use s because sudo -i doesnt work for passwordless sudo command
+  case $EUID in
+    0)
+      sudo nmtui-connect "$@"
+      ;;
+    *)
+      nmtui-connect "$@"
+      ;;
+  esac
 }
 
 nopanic() {
@@ -1567,7 +1583,7 @@ resolvcat() {
   grep '^ *hosts:' /etc/nsswitch.conf
   if systemctl is-enabled systemd-resolved &>/dev/null || [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then
     hr; m ser status systemd-resolved | cat || :
-    hr; m systemd-resolve --status | cat
+    hr; m resolvectl status | cat
   fi
 
 }
@@ -1724,7 +1740,7 @@ sk() {
 
   local quotes others
   quotes=2048,2068,2086,2206
-  others=2029,2033,2164
+  others=2029,2033,2054,2164
   shellcheck -W 999 -x -e $quotes,$others "$@" || return $?
 }
 
@@ -2167,6 +2183,23 @@ s/^\Wcapability: (.*)/\1/;Ta;h;b
 "|sort -r
 }
 
+# Run script by copying it to a temporary location first,
+# and changing directory, so we don't have any open
+# directories or files that could cause problems when
+# remounting.
+z() {
+  local tmp
+  tmp=$(type -p "$1")
+  if [[ $tmp ]]; then
+    cd $(mktemp -d)
+    cp -a "$tmp" .
+    shift
+    ./"${tmp##*/}" "$@"
+  else
+    "$@"
+  fi
+}
+
 # * misc stuff