mostly fixes
[distro-setup] / brc
diff --git a/brc b/brc
index c3747cf97e5a8b6f4e3de521db69f401c10b6281..02ad1a67b78073f1cb58f6bac878d3e64def4582 100644 (file)
--- a/brc
+++ b/brc
@@ -468,7 +468,7 @@ ccomp cd c
 
 bwm() {
   s bwm-ng -T avg -d
-  }
+}
 
 b() {
   local topb
@@ -1407,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() {
@@ -1732,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 $?
 }
 
@@ -2175,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