fix ssh issue, various minor improvements
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index 676c5973a760a2c7936cd24c901336a8f09b2727..1add8230a8766562b053460b415ce2915afd5018 100644 (file)
--- a/brc2
+++ b/brc2
@@ -395,16 +395,27 @@ astudio() {
 # becomes
 # https://brains.fsf.org/wiki/sysadmin/interns/2022/nick_shrader/intro_blog_post
 iki() {
-  local url path
+  local url path input
   if [[ $1 ]]; then
-    path="$*"
+    input="$*"
   else
-    read -r -p "enter path" path
+    read -r -p "enter path or url" input
   fi
-  url=$(readlink -f "$path")
-  url="https://brains.fsf.org/wiki/${url#*brains/}"
-  url="${url%.mdwn}"
-  echo "$url"
+  case $input in
+    http*)
+      path="/f/brains/${input##https://brains.fsf.org/wiki/}"
+      if [[ $path == */ ]]; then
+        path=${path%/}.mdwn
+        fi
+      j printf "%s\n" "$path"
+      ;;
+    *)
+      url=$(readlink -f "$input")
+      url="https://brains.fsf.org/wiki/${url#*brains/}"
+      url="${url%.mdwn}/"
+      j echo "$url"
+      ;;
+  esac
 
 }
 
@@ -1112,6 +1123,8 @@ beet2nav() {
 
 # pull in beets library locally
 beetpull() {
+  local sshfs_host
+  sshfs_host=b8.nz
   if [[ $HOSTNAME == kd ]]; then
     return 0
   fi
@@ -1120,7 +1133,7 @@ beetpull() {
     s chown iank:iank /i
   fi
   if ! mountpoint /i &>/dev/null; then
-    m sshfs b8.nz:/i /i
+    m sshfs $sshfs_host:/i /i
   fi
 }
 
@@ -1434,7 +1447,7 @@ sm() { # switch mail host
   c /
   # run latest
   keyhash=$(s ssh-keygen -lf /root/.ssh/home  | awk '{print $2}')
-  tmp=$(s ssh-add -l | awk '$2 == "'$keyhash'"')
+  tmp=$(s ssh-add -l | awk '$2 == "'$keyhash'"' ||:)
   if [[ ! $tmp ]]; then
     s ssh-add /root/.ssh/home
   fi
@@ -1562,7 +1575,11 @@ dsign() {
 # set day start for use in other programs.
 # expected to do be in a format like 830, or 800 or 1300.
 ds() {
-  echo $1 >/b/data/daystart
+  if [[ $1 ]]; then
+    echo $1 >/b/data/daystart
+  else
+    cat /b/data/daystart
+  fi
 }
 
 #### begin bitcoin related things
@@ -2573,9 +2590,17 @@ otp() {
   oathtool --totp -b "$*" | xclip -selection clipboard
 }
 j() {
-  "$@" |& pee "xclip -r -selection clipboard"
+  "$@" |& pee "xclip -r -selection clipboard" cat
 }
 
+# x copy
+xc() {
+  xclip -r -selection clipboard
+}
+# echo copy
+ec() {
+  pee "xclip -r -selection clipboard" cat
+}
 
 pakaraoke() {
   # from http://askubuntu.com/questions/456021/remove-vocals-from-mp3-and-get-only-instrumentals
@@ -3159,6 +3184,17 @@ fixu() {
   fi
 }
 
+# unmute
+um() {
+  pactl set-sink-mute @DEFAULT_SINK@ false
+  rm -f /tmp/ianknap
+}
+nap() {
+  pactl set-sink-mute @DEFAULT_SINK@ true
+  touch /tmp/ianknap
+}
+
+
 # systemctl is-enabled / status / cat says nothing, instead theres
 # some obscure symlink. paths copied from man systemd.unit.
 # possibly also usefull, but incomplete, doesnt show units not loaded in memory: