From: Ian Kelling Date: Fri, 21 Aug 2020 04:22:22 +0000 (-0400) Subject: simplify sl func, various improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=02fdd28e42d209c21db2d1f6fe03df3042869399;p=distro-setup simplify sl func, various improvements --- diff --git a/.bashrc b/.bashrc index 7a61595..09c5aa9 100644 --- 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 46651f1..f3cde8e 100644 --- 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 be1aca1..7f64bcc 100644 --- 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() { diff --git a/distro-begin b/distro-begin index 8595d1b..0c0dac0 100755 --- a/distro-begin +++ b/distro-begin @@ -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 diff --git a/distro-end b/distro-end index b99c242..73286c2 100755 --- a/distro-end +++ b/distro-end @@ -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 diff --git a/i3-sway/i3.conf b/i3-sway/i3.conf index 6d64b8f..473d8f5 100644 --- a/i3-sway/i3.conf +++ b/i3-sway/i3.conf @@ -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 +# } diff --git a/schrootupdate b/schrootupdate index b50c2a1..932d693 100755 --- a/schrootupdate +++ b/schrootupdate @@ -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 diff --git a/ssh-emacs-setup b/ssh-emacs-setup index ff3e2d0..426d098 100755 --- a/ssh-emacs-setup +++ b/ssh-emacs-setup @@ -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 diff --git a/subdir_files/.config/i3/config b/subdir_files/.config/i3/config index 8c6f2e1..ef9203d 100644 --- a/subdir_files/.config/i3/config +++ b/subdir_files/.config/i3/config @@ -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 +# }