fixes and improvements
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index 86512ded8458f407d748f7086795545f209a0d39..23cfd89aa14b5f1342229ca97acbf9abcf4b9eca 100644 (file)
--- a/brc2
+++ b/brc2
@@ -1283,7 +1283,7 @@ btrbk-date-sed() {
   done
 }
 jrbtrbk() {
-  jr -u btrbk-run -u btrbk -u switch-mail-host -u btrbk-spread "$@"
+  jr -u btrbk-run -u btrbk -u switch-mail-host "$@"
 }
 
 # internal function
@@ -1327,7 +1327,7 @@ btrbk-host-debug() {
 
     ## this takes a while, we only want to do it on 1st run
     # if [[ -s /tmp/b/$host.log ]]; then continue; fi
-    # ssh $host journalctl -u btrbk-run -u btrbk -u switch-mail-host -u btrbk-spread >/tmp/b/$host.log
+    # ssh $host journalctl -u btrbk-run -u btrbk -u switch-mail-host >/tmp/b/$host.log
   done
   gr '\bsnapshot success' /var/log/btrbk/*.log >/tmp/b/local.log
   cd /tmp/b
@@ -1385,8 +1385,6 @@ bbk() { # btrbk wrapper
       return 1
       ;;
   esac
-  # run latest
-  install-my-scripts
   # todo: consider changing this to srun and having the args come
   # from a file like /etc/default/btrbk, like is done in exim
   s jdo btrbk-run "$@"
@@ -1593,7 +1591,6 @@ sm() { # switch mail host
   if [[ ! $tmp ]]; then
     s ssh-add /root/.ssh/home
   fi
-  install-my-scripts
   s jdo switch-mail-host "$@"
   return $ret
 }
@@ -2295,11 +2292,6 @@ ccomp xdg-open o
 # jr() { journalctl "$@" | jfilter | less ; }
 # jrf() { journalctl -n 200 -f "$@" | jfilter; }
 
-jr() { journalctl "$@" ; }
-jrf() { journalctl -n 200 -f "$@" ; }
-
-
-ccomp journalctl jtail jr jrf
 
 ## old version for model01. i need to get that firmware working again.
 # kff() { # keyboardio firmware flash. you must hold down the tilde key
@@ -2534,6 +2526,10 @@ mnsnonet() {
 lom() {
   # l = the loopback device
   local l base
+  # get sudo pass cached right away
+  if ! sudo -nv 2>/dev/null; then
+    sudo -v
+  fi
   if [[ $1 == /* ]]; then
     base=${1##*/}
     fs_file=$1
@@ -3635,7 +3631,7 @@ rem() {
   find $paths -not \( -name .svn -prune -o -name .git -prune \
        -o -name .hg -prune -o -name .editor-backups -prune \
        -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto "$*" ||:
-  rgv -m 5 "$*" $paths ||:
+  rgv -m 5 "$*" $paths /a/t.org /p/w.org /a/work.org ||:
 }
 
 # setup:
@@ -3801,10 +3797,57 @@ fi
 # rg with respecting vcs ignore files
 rgv() {
   ret=0
-  command rg -. -z --no-messages -L -i -M 900 -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
+  # -. = search dotfiles
+  # -z = search zipped files
+  # -i = case insensitive
+  # -M = max columns
+  # --no-messages because of annoying errors on broken symlinks
+  command rg -. -z --no-messages -i -M 900 -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$?
   return $ret
 }
 
+amall() {
+  echo "$(tput setaf 5 2>/dev/null ||:)█ coresite █$(tput sgr0 2>/dev/null||:)"
+  amfsf "$@"
+  echo "$(tput setaf 5 2>/dev/null ||:)█ office █$(tput sgr0 2>/dev/null||:)"
+  amoffice "$@"
+}
+amallq() { # amall quiet
+  amfsf "$@"
+  amoffice "$@"
+}
+amfsf() {
+  sedi -r '/alertmanager.url/s/@prom.office/@prom/' ~/.config/amtool/config.yml
+  amtool "$@"
+}
+amoffice() {
+  sedi -r '/alertmanager.url/s/@prom.fsf/@prom.office.fsf/' ~/.config/amtool/config.yml
+  amtool "$@"
+}
+amls() {
+  amall silence query "$@"
+}
+amrmall() {
+  # note: not sure if quoting of this arg is correct
+  amfsf silence expire "$(amfsf silence query -q)"
+  amoffice silence expire "$(amoffice silence query -q)"
+}
+
+
+youtube-dl-update() {
+  sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
+  sudo chmod a+rx /usr/local/bin/youtube-dl
+}
+
+# https://github.com/yt-dlp/yt-dlp/wiki/Installation
+yt-dlp-update() {
+  sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
+sudo chmod a+rx /usr/local/bin/yt-dlp  # Make executable
+  }
+
+mpvyt() {
+  mpv --ytdl ytdl_path=/usr/local/bin/yt-dlp "$@"
+  }
 
 # taken from default changes to bashrc and bash_profile
 path-add --end --ifexists $HOME/.rvm/bin