install-my-scripts on mounting new subvol to use more up to date scripts
[distro-setup] / brc
diff --git a/brc b/brc
index e740a8da51db5889095452dcd71db179e710ab0c..84386907d92e1f4f53683068ac70ec77d73d48c5 100644 (file)
--- a/brc
+++ b/brc
@@ -188,8 +188,9 @@ if [[ $SOE ]]; then
 fi
 
 path_add /a/exe
-# end just because it seems safer
-path_add --end node_modules/.bin
+# add this with absolute paths as needed for better security
+#path_add --end /path/to/node_modules/.bin
+
 # pip3 --user things go here:
 path_add --end ~/.local/bin
 path_add --ifexists --end /a/work/libremanage
@@ -328,6 +329,18 @@ anki() {
   fi
 }
 
+ap() {
+  # pushd in case current directory has an ansible.cfg file
+  pushd /a/xans
+  ansible-playbook -v -l ${1:- $(hostname -f)} site.yml
+  popd
+}
+aw() {
+  pushd /a/work/ansible-configs
+  time ansible-playbook -v -i inventory adhoc.yml "$@"
+  popd
+}
+
 astudio() {
   # googling android emulator libGL error: failed to load driver: r600
   # lead to http://stackoverflow.com/a/36625175/14456
@@ -342,9 +355,20 @@ b() {
 
 bbk() {
   c /
+  local active=true
+  if systemctl is-active btrbk.service; then
+    echo "cron btrbk is already running"
+    return 1
+  fi
+  systemctl is-active btrbk.timer || active=false
+  if $active; then
+    ser disable btrbk.timer
+  fi
   # run latest
   install-my-scripts
-  btrbk-run "$@"
+  if ! btrbk-run "$@" && $active; then
+    ser enable btrbk.timer
+  fi
 }
 
 bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; }
@@ -924,7 +948,11 @@ gpg() {
 }
 
 gse() {
-  git send-email --notes '--envelope-sender=<ian@iankelling.org>' \
+  local email=ian@iankelling.org
+  if readlink ~/.mu | grep fsf &>/dev/null; then
+    email=iank@fsf.org
+  fi
+  git send-email --notes "--envelope-sender=<$email>" \
       --suppress-cc=self "$@"
 }
 
@@ -1264,6 +1292,21 @@ pfind() { #find *$1* in $PATH
   find "${pathArray[@]}" -iname "*$1*"
 }
 
+pkx() { # package extract
+  c `mktemp -d`
+  pkg=$1
+  cached=$(ls -t /var/cache/apt/archives/$1* | tail -n1)
+  if [[ $cached ]]; then
+    cp $cached .
+  else
+    aptitude download $pkg
+  fi
+  f=(*)
+  dtrx -m $f
+  dtrx -fr $f
+  rm -f $f
+}
+
 pk1() {
   local pid
   pid=($(pgrep -f "$*"))
@@ -2078,13 +2121,10 @@ if [[ $- == *i* ]]; then
     bind -m vi-command W:shell-forward-word
   fi
 
-  if [[ $SSH_CLIENT ]]; then
+  if [[ $SSH_CLIENT || $SUDO_USER ]]; then
     PS1="\h $PS1"
   fi
 
-
-
-
   prompt-command() {
     local return=$? # this MUST COME FIRST
     local psc pst ps_char ps_color stale_subvol
@@ -2116,6 +2156,9 @@ if [[ $- == *i* ]]; then
     if [[ -e /nocow/btrfs-stale ]] && ((`command ls -AUq /nocow/btrfs-stale|wc -l`)); then
       ps_char="! $ps_char"
     fi
+    if [[ ! $SSH_CLIENT && $MAIL_HOST != $HOSTNAME ]]; then
+      ps_char="@ $ps_char"
+    fi
     PS1="${PS1%"${PS1#*[wW]}"} \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "
     # emacs completion doesnt like the git prompt atm, so disabling it.
     #PS1="${PS1%"${PS1#*[wW]}"}$(__git_ps1 ' (%s)') \[$ps_color\]$ps_char\[$(get_term_color nocolor)\] "