simplify sl func, various improvements
authorIan Kelling <ian@iankelling.org>
Fri, 21 Aug 2020 04:22:22 +0000 (00:22 -0400)
committerIan Kelling <ian@iankelling.org>
Fri, 21 Aug 2020 04:22:22 +0000 (00:22 -0400)
.bashrc
brc
brc2
distro-begin
distro-end
i3-sway/i3.conf
schrootupdate
ssh-emacs-setup
subdir_files/.config/i3/config

diff --git a/.bashrc b/.bashrc
index 7a61595ab91366a8eb5535917bf6775bc35a50d9..09c5aa997879fc6a4b9b00208f3a215105f682e7 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -35,12 +35,12 @@ HISTIGNORE='pass *:[ ]*:otp *:oathtool *'
 #### begin section that works with sl() function to return from
 #### noninteractive ssh shells
 if [[ $SSH_CONNECTION ]] \
-     && [[ $BRC != t ]];  then
+     && [[ $LC_USEBASHRC != t ]];  then
   # Here we did not opt-in to running our .bashrc file so we just
   # return, but we still setup a function to source it without returning
   # so if we want it we don't have to restart our ssh connection.
   brc() {
-    export BRC=t
+    export LC_USEBASHRC=t
     source ~/.bashrc
   }
   return 0
diff --git a/brc b/brc
index 46651f1317d0444952149a3ace660c84fa3386fc..f3cde8e9df2dfb1b9b483c187ecd266d46677148 100644 (file)
--- a/brc
+++ b/brc
@@ -77,11 +77,11 @@ shopt -s globstar
 
 
 # inside emacs fixes
-if [[ $RLC_INSIDE_EMACS ]]; then
+if [[ $LC_INSIDE_EMACS ]]; then
   # EMACS is used by bash on startup, but we dont need it anymore.
   # plus I hit a bug in a makefile which inherited it
   unset EMACS
-  export RLC_INSIDE_EMACS
+  export LC_INSIDE_EMACS
   export PAGER=cat
   export MANPAGER=cat
   # scp completion does not work, but this doesnt fix it. todo, figure this out
@@ -132,7 +132,7 @@ if ! type -p stty >/dev/null; then
 fi
 if [[ $- == *i* ]]; then
   # for readline-complete.el
-  if [[ $RLC_INSIDE_EMACS ]]; then
+  if [[ $LC_INSIDE_EMACS ]]; then
     # all for readline-complete.el
     stty echo
     bind 'set horizontal-scroll-mode on'
@@ -295,7 +295,7 @@ b() {
 
 # c. better cd
 if type -p wcd &>/dev/null; then
-  if [[ $RLC_INSIDE_EMACS ]]; then
+  if [[ $LC_INSIDE_EMACS ]]; then
     c() { wcd -c -z 50 -o "$@"; }
   else
     # lets see what the fancy terminal does from time to time
@@ -1169,25 +1169,21 @@ sk() {
 # ~/.bashrc. You dont want this. .bashrc is meant for interactive shells
 # and if you customize it, probably has bugs from time to time. This is
 # bad. Here's how I fix it. I have a special condition to "return" in my
-# .bashrc for noninteractive ssh shells (copy that code). Then alter
-# AcceptEnv in /etc/ssh/sshd_config, adding the var BRC to it. And in
-# ~/.ssh/config or equivalent, add SendEnv BRC, plus any other
-# environment vars you want to send. Just that var should be fine. Then
-# use this function or similar that passes BRC=t when sshing. Also, I
+# .bashrc for noninteractive ssh shells (copy that code). Then
+# use this function or similar that passes LC_USEBASHRC=t when sshing. Also, I
 # don't keep most of my bashrc in .bashrc, i source a separate file
 # because even though I return, the whole file gets parsed which can
 # fail if there is a syntax error.
 sl() {
-  # Background on BRC var (no need to read if you just want to use this
+  # Background on LC_USEBASHRC var (no need to read if you just want to use this
   # function): bash builtin vars and env show no difference in ssh vs
   # local, except shell level which is not reliable. only reliable way I
   # found was env var. env variables sent across ssh are strictly
-  # limited. We could override an obscure unused LC_var, like telephone,
-  # but I don't want to run into some edge case where that messes things
-  # up. Note, on hosts we dont control I start an inner shell with BRC
-  # set, and the inner shell also allows running a nondefault
-  # .bashrc. This means the outer shell still ran the default .bashrc,
-  # but that is the best we can do.
+  # limited, but we get LC_*, so we just make that * be something no
+  # normal program would use. Note, on hosts that dont allow LC_* I start an
+  # inner shell with LC_USEBASHRC set, and the inner shell also allows running a
+  # nondefault .bashrc. This means the outer shell still ran the default
+  # .bashrc, but that is the best we can do.
 
   local now args remote dorsync haveinfo tmpa sshinfo tmp tmp2 type info_sec force_rsync sync_dirname
   declare -a args tmpa
@@ -1272,7 +1268,7 @@ sl() {
     fi
   else
     # use this weird yes thing to ensure we know ssh succeeded
-    if ! tmp=$(command ssh "${args[@]}" "$remote" "if test -e $SL_FILES_DIR/.bashrc -a -L .bashrc; then echo yes; fi"); then
+    if ! tmp=$(LC_USEBASHRC=yes command ssh "${args[@]}" "$remote" echo '$LC_USEBASHRC'); then
       echo failed sl test. doing plain ssh -v
       command ssh -v "${args[@]}" "$remote"
     fi
@@ -1297,20 +1293,20 @@ sl() {
       # Theres a couple ways to pass arguments, im not sure whats best,
       # but relying on bash 4.4+ escape quoting seems most reliable.
       command ssh "${args[@]}" "$remote" \
-              BRC=t bash -c '.\ '$sync_dirname'/.bashrc\;"\"\$@\""' bash ${@@Q}
+              LC_USEBASHRC=t bash -c '.\ '$sync_dirname'/.bashrc\;"\"\$@\""' bash ${@@Q}
     elif [[ ! -t 0 ]]; then
       # This case is when commands are being piped to ssh.
       # Normally, no bashrc gets sourced.
       # But, since we are doing all this, lets source it because we can.
-      cat <(echo . $sync_dirname/.bashrc) - | command ssh "${args[@]}" "$remote" BRC=t bash
+      cat <(echo . $sync_dirname/.bashrc) - | command ssh "${args[@]}" "$remote" LC_USEBASHRC=t bash
     else
-      command ssh -t "${args[@]}" "$remote" BRC=t INPUTRC=$sync_dirname/.inputrc bash --rcfile $sync_dirname/.bashrc
+      command ssh -t "${args[@]}" "$remote" LC_USEBASHRC=t INPUTRC=$sync_dirname/.inputrc bash --rcfile $sync_dirname/.bashrc
     fi
   else
     if [[ -t 0 ]]; then
-      BRC=t command ssh "${args[@]}" "$remote" ${@@Q}
+      LC_USEBASHRC=t command ssh "${args[@]}" "$remote" ${@@Q}
     else
-      command ssh "${args[@]}" "$remote" BRC=t bash
+      command ssh "${args[@]}" "$remote" LC_USEBASHRC=t bash
     fi
   fi
   # this function inspired from https://github.com/Russell91/sshrc
@@ -1328,7 +1324,7 @@ ssk() {
 }
 # plain ssh
 ssh() {
-  BRC=t command ssh "$@"
+  LC_USEBASHRC=t command ssh "$@"
 }
 
 
@@ -1557,7 +1553,7 @@ if [[ $- == *i* ]]; then
   shopt -s autocd
   shopt -s dirspell
   PS1='\w'
-  if [[ $- == *i* ]]  && [[ ! $RLC_INSIDE_EMACS ]]; then
+  if [[ $- == *i* ]]  && [[ ! $LC_INSIDE_EMACS ]]; then
     PROMPT_DIRTRIM=2
     bind -m vi-command B:shell-backward-word
     bind -m vi-command W:shell-forward-word
diff --git a/brc2 b/brc2
index be1aca165f6818aee41b4108fbc2108c1e3d9898..7f64bcc694fe0d11b3fdf9cb30643cc4a17cb3c6 100644 (file)
--- a/brc2
+++ b/brc2
@@ -77,11 +77,8 @@ ngreset() {
 }
 
 anki() {
-  if which anki &>/dev/null; then
-    command anki
-  else
-    schroot -c anki -- anki
-  fi
+  # crashes on adding new cards in t9
+  schroot -c buster -- anki
 }
 
 acat() {
index 8595d1bfafc248c82d2e7bc1b9ae0709f7e50cc6..0c0dac03da41a6d115c49bc220998fb15b4ebb71 100755 (executable)
@@ -262,7 +262,7 @@ rootsshsync
 set +x
 err-allow
 source /etc/profile.d/environment.sh
-export BRC=t
+export LC_USEBASHRC=t
 # shellcheck source=./.bashrc
 source ~/.bashrc
 err-catch
index b99c242b001c32c6e19fcf233f9eac15bc0d3ba9..73286c2fde4c73d5aa8e68b9648f369ab509b837 100755 (executable)
@@ -3,7 +3,7 @@
 # SPDX-License-Identifier: AGPL-3.0-or-later
 
 # shellcheck source=/a/bin/ds/.bashrc
-export BRC=t; if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
+export LC_USEBASHRC=t; if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi
 
 ### setup
 source /a/bin/errhandle/err
@@ -1091,7 +1091,7 @@ sgo schrootupdate.timer
 # for my roommate
 case $distro in
   trisquel)
-    m mkschroot debian buster firefox-esr pulseaudio chromium
+    m mkschroot debian buster firefox-esr pulseaudio chromium anki
     ;;
   debian)
     pi chromium
index 6d64b8f626c3c15bfb59174688e3ca0131c38a86..473d8f56c6122511e895462bff1466f09586ec4f 100644 (file)
@@ -3,10 +3,10 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu
 
 bindsym $mod+Shift+p restart
 
-bar {
-#status_command i3status
-#status_command          /usr/local/bin/myi3status
-mode hide
-hidden_state hide
-font pango:monospace 14
-}
+bar {
+# #status_command i3status
+# #status_command          /usr/local/bin/myi3status
+mode hide
+hidden_state hide
+font pango:monospace 14
+}
index b50c2a1606dad088288bcdc7653d6642cb175879..932d693334b22714032b4ae300659305debb20c7 100755 (executable)
@@ -5,7 +5,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
 
 [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
 
-for n in stretch; do
+for n in buster; do
   if [[ -e /etc/schroot/chroot.d/$n.conf ]]; then
     cd /
     schroot -c $n -- apt-get -y dist-upgrade --purge --auto-remove
index ff3e2d03fd90ce0a958ab5bc3e7fee2aad026e1f..426d098c4e37eb972409b210ef627850fa2f2f71 100755 (executable)
@@ -24,9 +24,6 @@ set -eE -o pipefail
 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR
 
 cd $(dirname $0)
-teeu /etc/ssh/ssh_config 'SendEnv INSIDE_EMACS BRC COLUMNS'
-## note, duplicated in /a/bin/fai/fai/config/scripts/GRUB_PC/11-iank
-teeu /etc/ssh/sshd_config 'AcceptEnv INSIDE_EMACS BRC COLUMNS'
 # get rid of useless motd stuff
 sed -i --follow-symlinks 's/^\s*PrintLastLog .*/PrintLastLog no/' /etc/ssh/sshd_config
 rm -f /etc/update-motd.d/10-help-text /etc/update-motd.d/00-header
index 8c6f2e1d7745c9753b3e529a5c5314a8e8094ed4..ef9203dc2ff71618604c96de0b4e3de0eb66dd84 100644 (file)
@@ -95,10 +95,10 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu
 
 bindsym $mod+Shift+p restart
 
-bar {
-#status_command i3status
-status_command          /usr/local/bin/myi3status
-mode hide
-hidden_state hide
-font pango:monospace 14
-}
+bar {
+# #status_command i3status
+# #status_command          /usr/local/bin/myi3status
+mode hide
+hidden_state hide
+font pango:monospace 14
+}