various minor fixes
[distro-setup] / brc
diff --git a/brc b/brc
index 9ec776de13572d0e3afca8b8d49d2564f9af3359..046edbed75a35594cde84f4cc3101bf8e9e5e7bd 100644 (file)
--- a/brc
+++ b/brc
@@ -7,10 +7,7 @@
 # trap 'trap ERR' RETURN
 
 
-
-############
-# settings #
-############
+# * settings
 
 CDPATH=.
 
@@ -109,6 +106,10 @@ if [[ $- == *i* ]]; then
     bind 'set print-completions-horizontally on'
     bind '"\C-i": self-insert'
   else
+
+    # todo: not sure this works in sakura
+    #stty werase undef
+    #bind "\C-w": kill-region
     # sakura == xterm-256color
     # konsole == xterm
     if [[ $TERM == "xterm" ]]; then
@@ -152,7 +153,7 @@ HISTCONTROL=ignoredups
 # works in addition to HISTCONTROL to do more flexible things
 # it could also do the same things as HISTCONTROL and thus replace it,
 # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
-HISTIGNORE='pass *:k *:[ ]*'
+HISTIGNORE='pass *:k *:[ ]*:lom '
 
 export BC_LINE_LENGTH=0
 
@@ -163,9 +164,7 @@ export BC_LINE_LENGTH=0
 C_DEFAULT_DIR=/a
 
 
-###################
-## include files ###
-###################
+# * include files
 for _x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do
   source "$_x"
 done
@@ -182,9 +181,7 @@ _x=/usr/share/wcd/wcd-include.sh
 if [[ -e $_x ]]; then source $_x; fi
 
 
-###############
-### aliases ###
-###############
+# * aliases
 
 # very few aliases, functions are always preferred.
 
@@ -210,15 +207,7 @@ unalias ls ll grep &>/dev/null ||:
 
 
 
-
-
-
-
-
-
-#####################
-###  functions   ####
-#####################
+# * functions
 
 
 ..() { c ..; }
@@ -865,6 +854,11 @@ gdkill() {
   pk1 emacs --daemon
 }
 
+# at least in flidas, things rely on gpg being gpg1
+gpg() {
+  command gpg2 "$@"
+}
+
 gse() {
   git send-email --notes '--envelope-sender=<ian@iankelling.org>' \
       --suppress-cc=self "$@"
@@ -876,20 +870,24 @@ gr() {
 
 grr() {
   if [[ ${#@} == 1 ]]; then
-    grep -riIP --color=auto "$@" .
+    grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@" .
   else
-    grep -riIP --color=auto "$@"
+    grep --exclude-dir='*.emacs.d' --exclude-dir='*.git' -riIP --color=auto "$@"
   fi
 }
 
 hstatus() {
   # do git status on published repos
   cd /a/bin/githtml
-  for x in !(forks) forks/* ian-specific/*; do
+  do_hr=false
+  for x in *; do
     cd `readlink -f $x`/..
-    hr
-    echo $x
-    i status
+    status=$(i status -s) || pwd
+    if [[ $status ]]; then
+      hr
+      echo $x
+      printf "%s\n" "$status"
+    fi
     cd /a/bin/githtml
   done
 }
@@ -1020,8 +1018,32 @@ l() {
 
 lcn() { locate -i "*$**"; }
 
+lt() { ll -tr "$@"; }
+
 lld() { ll -d "$@"; }
 
+lom() {
+  local l base
+  if [[ $1 == /* ]]; then
+    l=$(sudo losetup -f)
+    sudo losetup $l $1
+    base=${1##*/}
+    if ! sudo cryptsetup luksOpen $l $base; then
+      sudo losetup -d $l
+      return 1
+      fi
+    sudo mkdir -p /mnt/$base
+    sudo mount /dev/mapper/$base /mnt/$base
+    sudo chown $USER:$USER /mnt/$base
+  else
+    base=$1
+    sudo umount /mnt/$base
+    l=$(sudo cryptsetup status /dev/mapper/$base|sed -rn 's/^\s*device:\s*(.*)/\1/p')
+    sudo cryptsetup luksClose /dev/mapper/$base
+    sudo losetup -d $l
+  fi
+}
+
 low() {  # make filenames lowercase, remove bad chars
   local f new
   for f in "$@"; do
@@ -1082,6 +1104,7 @@ mbdisable() {
   set +x
 }
 
+
 mdt() {
   markdown "$1" >/tmp/mdtest.html
   firefox /tmp/mdtest.html
@@ -1103,10 +1126,17 @@ mkdir() { command mkdir -p "$@"; }
 
 mo() { xset dpms force off; } # monitor off
 
+
+nopanic() {
+  sudo tee -a /var/log/exim4/paniclog-archive </var/log/exim4/paniclog; sudo truncate -s0 /var/log/exim4/paniclog
+}
+
+
 otp() {
   oathtool --totp -b "$@" | xclip -selection clipboard
 }
 
+p8() { ping 8.8.8.8; }
 
 pakaraoke() {
   # from http://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals
@@ -1159,7 +1189,6 @@ pick-trash() {
   done
 }
 
-ping8() { ping 8.8.8.8; }
 
 pub() {
   rld /a/h/_site/ li:/var/www/iankelling.org/html
@@ -1250,7 +1279,7 @@ rlu() { # [OPTS] HOST PATH
   s rsync -rlpchviog --relative "${opts[@]}" "$path" "root@$host:/";
 }
 
-# only run on desktop. simpler to keep this on one system.
+# only run on MAIL_HOST. simpler to keep this on one system.
 r2eadd() { # usage: name url
   # initial setup of rss2email:
   # r2e new r2e@iankelling.org
@@ -1445,6 +1474,10 @@ splay() { # script replay
   scriptreplay "$1.t" "$1.s"
 }
 
+spd() {
+  PATH=/usr/local/spdhackfix:$PATH command spd "$@"
+}
+
 spend() {
   s systemctl suspend
 }
@@ -1663,10 +1696,14 @@ m() { printf "%s\n" "$*";  "$@"; }
 
 
 vpncmd() {
+  #m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*pia.conf") -n -m "$@"
   m s nsenter -t $(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf") -n -m "$@"
 }
 vpnf() {
-  vpncmd gksudo -u iank "firefox -no-remote -P firefox-main-profile" &r
+  vpncmd gksudo -u iank "firefox -no-remote -P vpn" &r
+}
+vpni() {
+  vpncmd gksudo -u iank "$*"
 }
 vpnbash() {
   vpncmd bash
@@ -1761,9 +1798,7 @@ xl() {
   xscreensaver-command -activate
 }
 
-#############################
-######### misc stuff ########
-#############################
+# * misc stuff
 
 # from curl cheat.sh/:bash_completion
 _cheatsh_complete_curl()
@@ -1854,12 +1889,7 @@ unset safe_term match_lhs use_color
 
 
 
-
-
-
-###############
-# prompt ######
-###############
+# * prompt
 
 
 if [[ $- == *i* ]]; then
@@ -1999,9 +2029,7 @@ EOF
 }
 
 
-###########################################
-# stuff that makes sense to be at the end #
-###########################################
+# * stuff that makes sense to be at the end
 if [[ "$SUDOD" ]]; then
   cd "$SUDOD"
   unset SUDOD