# 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
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'
# 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
# ~/.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
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
# 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
}
# plain ssh
ssh() {
- BRC=t command ssh "$@"
+ LC_USEBASHRC=t command ssh "$@"
}
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