2017-03-29 17:45:16 -05:00
|
|
|
#
|
2017-10-10 10:37:30 -05:00
|
|
|
# /etc/bashrc
|
2017-03-29 17:45:16 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
# If not running interactively, don't do anything
|
|
|
|
[[ $- != *i* ]] && return
|
|
|
|
|
2019-05-06 02:31:16 -05:00
|
|
|
### Prompt ###
|
2020-11-09 04:29:47 -06:00
|
|
|
organization="$(echo $HOSTNAME | rev | cut -f 2 -d '.' | rev)"
|
|
|
|
PS1='\[\033[00;31m\][ \[\033[01;32m\]\u\[\033[00;31m\]@\H:${SHELL} {\[\033[m\]$? \[\033[00;36m\]\D{%F-%R} \[\033[00;35m\]\w\[\033[00;31m\]\[\033[00;31m\]\[\033[00;33m\]$(git_prompt_var)\[\033[00;31m\]} ]\n|\[\033[m\]> '
|
2017-03-29 17:45:16 -05:00
|
|
|
PS2='> '
|
|
|
|
PS3='> '
|
|
|
|
PS4='+ '
|
|
|
|
case ${TERM} in
|
2020-11-09 04:29:47 -06:00
|
|
|
screen|xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
|
|
|
|
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'/${HOSTNAME%%.*}"'
|
2017-03-29 17:45:16 -05:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-11-09 04:29:47 -06:00
|
|
|
# Terminal settings
|
|
|
|
export TERM=xterm-256color
|
|
|
|
alias weechat="TERM=screen weechat"
|
|
|
|
|
|
|
|
# Disable bracketed paste mode
|
|
|
|
printf "\e[?2004l"
|
|
|
|
|
2019-05-06 02:04:19 -05:00
|
|
|
### MOTD ###
|
2017-03-29 17:45:16 -05:00
|
|
|
[ -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'
|
2020-06-15 17:11:37 -05:00
|
|
|
function vncdesktop() {
|
|
|
|
set -x
|
|
|
|
if [ -z "$@" ]; then
|
|
|
|
vncserver :2 -rfbport 5901
|
|
|
|
else
|
|
|
|
vncserver $@
|
|
|
|
fi
|
|
|
|
export DISPLAY=`vncserver -list | tail -n 1 | awk '{print $1; }' `
|
|
|
|
sleep 3
|
|
|
|
xfce4-session
|
|
|
|
vncserver -kill "$DISPLAY"
|
|
|
|
set +x
|
|
|
|
}
|
2017-03-29 17:45:16 -05:00
|
|
|
alias vi=vim
|
|
|
|
alias view="vim -R"
|
|
|
|
alias top="top -o %CPU"
|
|
|
|
alias make-entrypoints="egrep '^[a-zA-Z0-9\-]*:' Makefile"
|
2017-10-25 23:50:52 -05:00
|
|
|
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
|
2017-03-29 17:45:16 -05:00
|
|
|
IFS="
|
|
|
|
"
|
|
|
|
|
2020-06-15 17:11:37 -05:00
|
|
|
### GIT ###
|
2020-11-09 04:29:47 -06:00
|
|
|
source /usr/share/git/completion/git-prompt.sh
|
2020-06-15 17:11:37 -05:00
|
|
|
|
|
|
|
function git_prompt_var() {
|
|
|
|
### If $PWD is a Git repo, add URL and branch to PS1
|
|
|
|
url=`git config remote.origin.url 2>/dev/null`
|
|
|
|
if [ -n "$url" ]; then
|
|
|
|
branch=`__git_ps1 '%s'`
|
|
|
|
url=`basename "$url"`
|
|
|
|
echo " $url($branch)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2019-05-06 02:04:19 -05:00
|
|
|
### SSH ###
|
|
|
|
# Tell shell about ssh-agent -- enable with 'systemctl enable ssh-agent@$USER.service'
|
2020-11-09 04:29:47 -06:00
|
|
|
export SSH_AGENT_PID="$(pgrep -fu "$USER" ssh-agent)"
|
2019-05-06 02:04:19 -05:00
|
|
|
if [ -n "$SSH_AGENT_PID" ]; then
|
2019-05-18 11:10:39 -05:00
|
|
|
export SSH_AUTH_SOCK="$(ls -ld /tmp/ssh-*/agent.* | grep -m 1 "$USER" | awk '{ print $9; }')"
|
2019-05-06 02:04:19 -05:00
|
|
|
echo ssh-agent PID is $SSH_AGENT_PID
|
|
|
|
fi
|
2020-06-15 17:11:37 -05:00
|
|
|
if [ -n "$SSH_AUTH_SOCK" ] && [ `ssh-add -L | grep -c no\ identities` -eq 1 ]; then
|
|
|
|
ssh-add
|
|
|
|
ssh-add -L
|
|
|
|
fi
|
|
|
|
|
2020-11-09 04:29:47 -06:00
|
|
|
### GPG ###
|
|
|
|
export GPG_TTY=$(tty)
|
|
|
|
|
|
|
|
### Ansible ###
|
|
|
|
export ANSIBLE_VAULT_PASSWORD_FILE=$HOME/password-store/${organization}.vault.password
|
|
|
|
export ANSIBLE_VAULT_FILE=$HOME/password-store/${organization}.vault
|
|
|
|
|
2020-06-15 17:11:37 -05:00
|
|
|
# ### User-directory .gitbare Support (Git) ###
|
|
|
|
# if [ -d ~/.git ]; then
|
|
|
|
# cd
|
|
|
|
# printf "~/.git: "
|
|
|
|
# if [ $SHLVL -eq 1 ] && [ -z "$TMUX" ]; then
|
|
|
|
# git pull
|
|
|
|
# else
|
|
|
|
# git rev-parse --short HEAD
|
|
|
|
# fi
|
|
|
|
# git status
|
|
|
|
# fi
|
|
|
|
#
|
2017-10-10 10:37:30 -05:00
|
|
|
# Set up screen/tmux safety nest by default for remote sessions
|
2020-11-09 04:29:47 -06:00
|
|
|
if [ -n "$SSH_CLIENT" ]; then
|
2019-05-06 02:04:19 -05:00
|
|
|
# Prefer tmux
|
2017-03-29 17:45:16 -05:00
|
|
|
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 ':'`
|
2017-10-10 10:37:30 -05:00
|
|
|
else
|
|
|
|
tmux list-sessions
|
|
|
|
fi
|
2017-06-23 13:56:31 -05:00
|
|
|
alias tat="exec tmux a -d -t"
|
2017-03-29 17:45:16 -05:00
|
|
|
fi;
|
2019-05-06 02:04:19 -05:00
|
|
|
|
|
|
|
### 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
|
2017-10-25 23:50:52 -05:00
|
|
|
exec startxfce4
|
2017-03-29 17:45:16 -05:00
|
|
|
fi
|