ShadowArch/EtcFiles/bashrc
2019-05-06 02:31:16 -05:00

83 lines
3.1 KiB
Bash

#
# /etc/bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
### Prompt ###
organization="$(hostname | rev | cut -f 2 -d '.' | rev)"
PS1='\[\033[00;31m\][ '"${organization^^}"'::\h/\[\033[01;32m\]\u \[\033[00;31m\]\\\\\\\\ ${SHELL} {\[\033[m\]$? \[\033[00;36m\]\D{%F-%R} \[\033[00;35m\]\w\[\033[00;31m\]\[\033[00;31m\]} ]\n|\[\033[m\]> '
PS2='> '
PS3='> '
PS4='+ '
case ${TERM} in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;AniNIX::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
;;
screen)
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;AniNIX::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
;;
esac
### MOTD ###
[ -f /etc/bash.motd ] && cat /etc/bash.motd
### AniNIX Customizations ###
alias get-commands='for i in $( echo $PATH | sed "s/:/\n/g"); do ls $i; done | sort | less'
alias whoison='who | grep -v tmux'
alias startvnc="vncserver -xstartup startxfce4; echo Use \"ssh -L 5901:localhost:5901 $(whoami)@$(hostname)\" to tunnel connections."
alias vi=vim
alias view="vim -R"
alias top="top -o %CPU"
alias make-entrypoints="egrep '^[a-zA-Z0-9\-]*:' Makefile"
if [ -x `which torsocks 2>/dev/null` ] && [ `systemctl status tor 2>/dev/null| grep -c running` -eq 1 ]; then
alias tor-lynx="torsocks lynx https://check.torproject.org/";
fi
IFS="
"
### SSH ###
# Aliases for hosts
if [ -f ~/.ssh/config ]; then
for i in `egrep '^Host' ~/.ssh/config | grep -v \* | cut -f 2 -d ' '`; do
alias "$i"="ssh $i";
done
fi
# Tell shell about ssh-agent -- enable with 'systemctl enable ssh-agent@$USER.service'
SSH_AGENT_PID="$(ps -feu "$USER" | grep -v grep | grep -m 1 ssh-agent | awk '{ print $2; }')"
if [ -n "$SSH_AGENT_PID" ]; then
SSH_AUTH_SOCK="$(ls -1 /tmp/ssh-*/agent.$(( $SSH_AGENT_PID - 1 )))"
echo ssh-agent PID is $SSH_AGENT_PID
fi
# Set up screen/tmux safety nest by default for remote sessions
if [ ! -z "$SSH_CLIENT" ]; then
# Prefer tmux
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 ':'`
else
tmux list-sessions
fi
alias tat="exec tmux a -d -t"
# Fallback on Screen
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
else
screen -list
fi
alias sdr="screen -d -r"
fi;
### XFCE4 ###
elif [ `who -m | egrep "^$(whoami)" | awk '{ print $2; }' | egrep -c "^tty"` -eq 1 ] && [ -x /usr/sbin/startxfce4 ] && [ `pgrep -ac xinit` -eq 0 ] && [ `whoami` != 'root' ]; then
exec startxfce4
fi