From e4afa2e8e5f6aba12972b130c82296996384ce4e Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Tue, 10 Oct 2017 10:37:30 -0500 Subject: [PATCH] Fixes for bashrc --- ShadowArch/Makefile | 10 +++------- ShadowArch/{bash.bashrc => bashrc} | 24 ++++++++++++++++-------- ShadowArch/profile | 4 ++-- 3 files changed, 21 insertions(+), 17 deletions(-) rename ShadowArch/{bash.bashrc => bashrc} (86%) diff --git a/ShadowArch/Makefile b/ShadowArch/Makefile index 204378f..fc3bb56 100644 --- a/ShadowArch/Makefile +++ b/ShadowArch/Makefile @@ -1,17 +1,13 @@ HTTPROOT = /srv/http/aninix.net 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 compile: ./shadowarch @echo Nothing to compile install: compile - cp ./vimrc /etc/vimrc - cp bash.bashrc /etc/bash.bashrc - rsync -avz -r skel/ /etc/skel - cp tmux.conf /etc/tmux.conf - cp ./profile /etc/profile + for i in ${SYNCLIST}; do rsync -avz -r `echo $$i | sed 's#^/etc/##'` $$i; done # This is a nicety. 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 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 ./shadowarch ${HTTPROOT}/shadowarch diff --git a/ShadowArch/bash.bashrc b/ShadowArch/bashrc similarity index 86% rename from ShadowArch/bash.bashrc rename to ShadowArch/bashrc index 8f8d00c..45bb610 100644 --- a/ShadowArch/bash.bashrc +++ b/ShadowArch/bashrc @@ -1,5 +1,5 @@ # -# /etc/bash.bashrc +# /etc/bashrc # # If not running interactively, don't do anything @@ -20,6 +20,8 @@ case ${TERM} in ;; esac +# Considered untrusted. +# https://bugs.archlinux.org/task/55841 [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion [ -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"; done -# Set up screen/tmux safety nest by default. -if [ "$TERM" != "screen" ] && [ -z "$DESKTOP_SESSION" ]; then +# SSH +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 [ `tmux list-sessions | grep created | wc -l` -eq 0 ]; then exec tmux 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 ':'` - fi + else + tmux list-sessions + fi alias tat="exec tmux a -d -t" elif [ -x "$(which screen 2>/dev/null)" ] && [ "$TERM" != "screen" ]; then if [ `screen -list | grep -c 'Detached'` -eq 1 ]; then exec screen -r elif [ `screen -list | grep -c 'No Sockets found in '` -eq 1 ] && [ "$TERM" != "screen" ]; then exec /usr/bin/screen /bin/bash - fi + else + screen -list + fi alias sdr="screen -d -r" fi; fi - -# Autocompletions are having trouble lately and spawning irssi -- can't find where yet TODO -complete -r diff --git a/ShadowArch/profile b/ShadowArch/profile index 6aa485b..104de54 100644 --- a/ShadowArch/profile +++ b/ShadowArch/profile @@ -19,8 +19,8 @@ if test -d /etc/profile.d/; then fi # Source global bash config -if test "$PS1" && test "$BASH" && test -r /etc/bash.bashrc; then - . /etc/bash.bashrc +if test "$PS1" && test "$BASH" && test -r /etc/bashrc; then + . /etc/bashrc fi # Termcap is outdated, old, and crusty, kill it.