option for disabling status for less distraction
[distro-setup] / brc
diff --git a/brc b/brc
index aaaf87ce3e2156f9c9dd3916f622ed1ca1ed2414..a47a6fa6cb6d99ef82ae7eb6be6742e868958bf8 100644 (file)
--- a/brc
+++ b/brc
@@ -7,16 +7,16 @@
 # so this can set extdebug and avoid the bash debugger.
 
 
-if [[ -s /a/bin/errhandle/err ]]; then
-  # shellcheck source=/a/bin/errhandle/err
-  source /a/bin/errhandle/err
+if [[ -s /a/bin/bash-bear-trap/bash-bear ]]; then
+  # shellcheck source=/a/bin/bash-bear-trap/bash-bear
+  source /a/bin/bash-bear-trap/bash-bear
   # wtf, shellcheck doesn't allow disabling warnings in elifs
 else
   # bleh shellcheck can't handle disabling in an elif, so nesting this if.
   # shellcheck disable=SC2154 # set in .bashrc
-  if [[ -s $bashrc_dir/err ]]; then
-    # shellcheck source=/a/bin/errhandle/err
-    source $bashrc_dir/err
+  if [[ -s $bashrc_dir/bash-bear ]]; then
+    # shellcheck source=/a/bin/bash-bear-trap/bash-bear
+    source $bashrc_dir/bash-bear
   fi
 fi
 
@@ -282,8 +282,8 @@ fi
 # bash: /usr/share/bashdb/bashdb-main.inc: No such file or directory
 # bash: warning: cannot start debugger; debugging mode disabled
 if [[ $SOE ]]; then
-  if [[ -e /a/bin/errhandle/err ]]; then
-    source /a/bin/errhandle/err
+  if [[ -e /a/bin/bash-bear-trap/bash-bear ]]; then
+    source /a/bin/bash-bear-trap/bash-bear
   fi
 fi
 
@@ -561,6 +561,21 @@ bl() {
     fi
   done
 }
+# like running cl <enter> a <enter>
+cla() {
+  local line
+  mapfile -t lines <~/.cdirs
+  start=$(( ${#lines[@]} - 1 ))
+  for (( j=start; j >= 0; j-- )); do
+    line="${lines[$j]}"
+    if [[ ! $line || ! -d "$line" || $line == "$PWD" || line == "$HOME"  ]]; then
+      continue
+    fi
+    e "$line"
+    c "$line"
+    break
+  done
+}
 ## END functions to change directory better than cd ##
 
 # pee do. run args as a command with output copied to syslog.
@@ -710,6 +725,7 @@ khcopy() {
   ssh-copy-id $1
 }
 
+# copy path into clipboard
 a() {
   local x
   x=$(readlink -nf "${1:-$PWD}")
@@ -818,15 +834,15 @@ cf() {
 caf() {
 
   local file
-find -L "$@" -type f -not \( -name .svn -prune -o -name .git -prune \
+  find -L "$@" -type f -not \( -name .svn -prune -o -name .git -prune \
        -o -name .hg -prune -o -name .editor-backups -prune \
        -o -name .undo-tree-history -prune \) -printf '%h\0%d\0%p\n' | sort -t '\0' -n \
-  | awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
+    | awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
     hr
     printf "%s\n" "$file"
     hr
     cat "$file"
-done
+  done
 }
 ccomp cat cf caf
 
@@ -840,7 +856,7 @@ clc() {
 
 cx() {
   chmod +X "$@"
-  }
+}
 
 cam() {
   git commit -am "$*"
@@ -1436,6 +1452,27 @@ g() {
   fi
 }
 
+# g pipe. like: cmd | emacs. save cmd output to tmp file, then edit.
+gp() {
+  cat &>/a/tmp/gtmp
+  g "$@" /a/tmp/gtmp
+}
+# g log
+#like cmd &> tempfile; emacs tempfile
+#
+# note: a useful workflow for doing mass replace on my files:
+# gc rem REGEX
+## remove any false positives, or manually edit them. rename files if needed.
+# sedi 's/REGEX/REPLACEMENT/' $(gr '^/' /a/tmp/gtmp)
+gl() {
+  "$@" &> /a/tmp/gtmp
+  g /a/tmp/gtmp
+}
+# g command substitution
+gc() {
+  g $("$@")
+}
+
 # force terminal version
 gn() {
   g -n "$@"
@@ -2030,6 +2067,8 @@ sedi() {
   sed -i --follow-symlinks "$@"
 }
 
+
+
 rmstrips() {
   ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less
 }
@@ -2772,6 +2811,8 @@ leap-year() {
 # on-battery
 on-bat() {
   if [[ -e /sys/class/power_supply/AC/online && $(</sys/class/power_supply/AC/online) == 0 ]]; then
+    return 0
+  else
     return 1
   fi
 }
@@ -2795,11 +2836,11 @@ lsc() {
 # run then notify. close notification after the next prompt.
 rn() {
   "$@"
-  dunstify -u critical "$*"
+  dunstify -u critical -h string:x-dunst-stack-tag:profanity "$*"
   _psrun=(dunstctl close-all)
 }
 n() {
-  dunstify -u critical n
+  dunstify -u critical -h string:x-dunst-stack-tag:profanity n
   _psrun=(dunstctl close-all)
 }
 
@@ -2817,6 +2858,30 @@ cm() {
 }
 
 
+disk-info() {
+  local cmds cmd
+  mapfile -t cmds <<'EOF'
+tail -n +1 /proc/mdstat /etc/mdadm/mdadm.conf /etc/fstab /etc/crypttab
+lsblk
+blkid
+ls -la /dev/disk/by-id
+EOF
+
+  for cmd in "${cmds[@]}"; do
+    cat <<EOF
+### $cmd
+
+\`\`\`
+EOF
+    $cmd
+    cat <<'EOF'
+
+```
+
+EOF
+  done
+}
+
 # * misc stuff