Fixes for bashrc

This commit is contained in:
DarkFeather 2017-10-10 10:37:30 -05:00
parent 3f04d3265d
commit e4afa2e8e5
3 changed files with 21 additions and 17 deletions

View File

@ -1,17 +1,13 @@
HTTPROOT = /srv/http/aninix.net HTTPROOT = /srv/http/aninix.net
HTTPUSER = http HTTPUSER = http
SYNCLIST = /etc/vimrc /etc/bash.bashrc /etc/skel /etc/tmux.conf /etc/profile SYNCLIST = /etc/vimrc /etc/bashrc /etc/skel /etc/tmux.conf /etc/profile
INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash INSTALLER != curl -s https://aninix.net/foundation/installer-test.bash | /bin/bash
compile: ./shadowarch compile: ./shadowarch
@echo Nothing to compile @echo Nothing to compile
install: compile install: compile
cp ./vimrc /etc/vimrc for i in ${SYNCLIST}; do rsync -avz -r `echo $$i | sed 's#^/etc/##'` $$i; done
cp bash.bashrc /etc/bash.bashrc
rsync -avz -r skel/ /etc/skel
cp tmux.conf /etc/tmux.conf
cp ./profile /etc/profile
# This is a nicety. # This is a nicety.
if [ -f /root/shadowarch* ]; then sed -i 's/`uname -o`/ShadowArch/g' /etc/bash.bashrc; fi if [ -f /root/shadowarch* ]; then sed -i 's/`uname -o`/ShadowArch/g' /etc/bash.bashrc; fi
@ -35,7 +31,7 @@ reverse: ${HTTPROOT}/shadowarch ${SYNCLIST}
sed -i 's/ShadowArch/`uname -o`/' ./bash.bashrc sed -i 's/ShadowArch/`uname -o`/' ./bash.bashrc
clean: clean:
@echo Nothing to do. if [ -f /etc/bash.bashrc ]; then printf "Remove /etc/bash.bashrc? [y/n] "; read answer; if [ "$$answer" == "y" ]; then rm /etc/bash.bashrc; fi; fi
diff: ${HTTPROOT}/shadowarch ${SYNCLIST} diff: ${HTTPROOT}/shadowarch ${SYNCLIST}
diff ./shadowarch ${HTTPROOT}/shadowarch diff ./shadowarch ${HTTPROOT}/shadowarch

View File

@ -1,5 +1,5 @@
# #
# /etc/bash.bashrc # /etc/bashrc
# #
# If not running interactively, don't do anything # If not running interactively, don't do anything
@ -20,6 +20,8 @@ case ${TERM} in
;; ;;
esac esac
# Considered untrusted.
# https://bugs.archlinux.org/task/55841
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
[ -f /etc/bash.motd ] && cat /etc/bash.motd [ -f /etc/bash.motd ] && cat /etc/bash.motd
@ -43,24 +45,30 @@ for i in `ls -d ~/.irssi-* 2>/dev/null`; do
alias `echo $i | cut -f 2 -d '-' | tr '[:upper:]' '[:lower:]'`="irssi --home=$i"; alias `echo $i | cut -f 2 -d '-' | tr '[:upper:]' '[:lower:]'`="irssi --home=$i";
done done
# Set up screen/tmux safety nest by default. # SSH
if [ "$TERM" != "screen" ] && [ -z "$DESKTOP_SESSION" ]; then for i in `egrep '^Host' ~/.ssh/config | cut -f 2 -d ' '`; do
alias "$i"="ssh $i";
done
# Set up screen/tmux safety nest by default for remote sessions
if [ ! -z "$SSH_CLIENT" ]; then
if [ -x "$(which tmux 2>/dev/null)" ] && [ -z "$TMUX" ]; then if [ -x "$(which tmux 2>/dev/null)" ] && [ -z "$TMUX" ]; then
if [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then if [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then
exec tmux exec tmux
elif [ `tmux list-sessions | grep created | wc -l` -eq 1 ] && [ `tmux list-sessions | grep attached | wc -l` -eq 0 ]; then elif [ `tmux list-sessions | grep created | wc -l` -eq 1 ] && [ `tmux list-sessions | grep attached | wc -l` -eq 0 ]; then
exec tmux a -d -t `tmux list-sessions | grep created | cut -f 1 -d ':'` exec tmux a -d -t `tmux list-sessions | grep created | cut -f 1 -d ':'`
fi else
tmux list-sessions
fi
alias tat="exec tmux a -d -t" alias tat="exec tmux a -d -t"
elif [ -x "$(which screen 2>/dev/null)" ] && [ "$TERM" != "screen" ]; then elif [ -x "$(which screen 2>/dev/null)" ] && [ "$TERM" != "screen" ]; then
if [ `screen -list | grep -c 'Detached'` -eq 1 ]; then if [ `screen -list | grep -c 'Detached'` -eq 1 ]; then
exec screen -r exec screen -r
elif [ `screen -list | grep -c 'No Sockets found in '` -eq 1 ] && [ "$TERM" != "screen" ]; then elif [ `screen -list | grep -c 'No Sockets found in '` -eq 1 ] && [ "$TERM" != "screen" ]; then
exec /usr/bin/screen /bin/bash exec /usr/bin/screen /bin/bash
else
screen -list
fi fi
alias sdr="screen -d -r" alias sdr="screen -d -r"
fi; fi;
fi fi
# Autocompletions are having trouble lately and spawning irssi -- can't find where yet TODO
complete -r

View File

@ -19,8 +19,8 @@ if test -d /etc/profile.d/; then
fi fi
# Source global bash config # Source global bash config
if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then if test "$PS1" && test "$BASH" && test -r /etc/bashrc; then
. /etc/bash.bashrc . /etc/bashrc
fi fi
# Termcap is outdated, old, and crusty, kill it. # Termcap is outdated, old, and crusty, kill it.