Updates for profile and bashrc; PS1 simplification
This commit is contained in:
		@@ -6,21 +6,24 @@
 | 
			
		||||
[[ $- != *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\]\[\033[00;33m\]$(git_prompt_var)\[\033[00;31m\]} ]\n|\[\033[m\]> '
 | 
			
		||||
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\]> '
 | 
			
		||||
PS2='> '
 | 
			
		||||
PS3='> '
 | 
			
		||||
PS4='+ '
 | 
			
		||||
case ${TERM} in
 | 
			
		||||
    xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
 | 
			
		||||
        PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
 | 
			
		||||
 | 
			
		||||
        ;;
 | 
			
		||||
    screen)
 | 
			
		||||
        PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'::%s \134\134 %s in %s\007" "${HOSTNAME%%.*}" "${USER}" "${PWD/#$HOME/\~}"'
 | 
			
		||||
    screen|xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
 | 
			
		||||
        PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;'${organization^^}'/${HOSTNAME%%.*}"'
 | 
			
		||||
        ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
# Terminal settings
 | 
			
		||||
export TERM=xterm-256color
 | 
			
		||||
alias weechat="TERM=screen weechat"
 | 
			
		||||
 | 
			
		||||
# Disable bracketed paste mode
 | 
			
		||||
printf "\e[?2004l"
 | 
			
		||||
 | 
			
		||||
### MOTD ###
 | 
			
		||||
[ -f /etc/bash.motd ] && cat /etc/bash.motd
 | 
			
		||||
 | 
			
		||||
@@ -51,7 +54,7 @@ IFS="
 | 
			
		||||
"
 | 
			
		||||
 | 
			
		||||
### GIT ###
 | 
			
		||||
source /usr/share/git-core/contrib/completion/git-prompt.sh
 | 
			
		||||
source /usr/share/git/completion/git-prompt.sh
 | 
			
		||||
 | 
			
		||||
function git_prompt_var() {
 | 
			
		||||
    ### If $PWD is a Git repo, add URL and branch to PS1
 | 
			
		||||
@@ -65,7 +68,7 @@ function git_prompt_var() {
 | 
			
		||||
 | 
			
		||||
### SSH ###
 | 
			
		||||
# Tell shell about ssh-agent -- enable with 'systemctl enable ssh-agent@$USER.service'
 | 
			
		||||
export SSH_AGENT_PID="$(ps -fu "$USER" | grep -v grep | grep -m 1 ssh-agent | awk '{ print $2; }')"
 | 
			
		||||
export SSH_AGENT_PID="$(pgrep -fu "$USER" ssh-agent)"
 | 
			
		||||
if [ -n "$SSH_AGENT_PID" ]; then
 | 
			
		||||
    export SSH_AUTH_SOCK="$(ls -ld /tmp/ssh-*/agent.* | grep -m 1 "$USER" | awk '{ print $9; }')"
 | 
			
		||||
    echo ssh-agent PID is $SSH_AGENT_PID
 | 
			
		||||
@@ -75,6 +78,13 @@ if [ -n "$SSH_AUTH_SOCK" ] && [ `ssh-add -L | grep -c no\ identities` -eq 1 ]; t
 | 
			
		||||
    ssh-add -L
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
### 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
 | 
			
		||||
 | 
			
		||||
# ### User-directory .gitbare Support (Git) ###
 | 
			
		||||
# if [ -d ~/.git ]; then
 | 
			
		||||
#     cd 
 | 
			
		||||
@@ -88,7 +98,7 @@ fi
 | 
			
		||||
# fi
 | 
			
		||||
# 
 | 
			
		||||
# Set up screen/tmux safety nest by default for remote sessions
 | 
			
		||||
if [ ! -z "$SSH_CLIENT" ]; then 
 | 
			
		||||
if [ -n "$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
 | 
			
		||||
@@ -99,20 +109,9 @@ if [ ! -z "$SSH_CLIENT" ]; then
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,30 @@
 | 
			
		||||
#Set our umask
 | 
			
		||||
umask 022
 | 
			
		||||
 | 
			
		||||
# Set our default path
 | 
			
		||||
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/bin"
 | 
			
		||||
# Append "$1" to $PATH when not already in.
 | 
			
		||||
# This function API is accessible to scripts in /etc/profile.d
 | 
			
		||||
append_path () {
 | 
			
		||||
    case ":$PATH:" in
 | 
			
		||||
        *:"$1":*)
 | 
			
		||||
            ;;
 | 
			
		||||
        *)
 | 
			
		||||
            PATH="${PATH:+$PATH:}$1"
 | 
			
		||||
    esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Append our default paths
 | 
			
		||||
append_path '/usr/local/sbin'
 | 
			
		||||
append_path '/usr/local/bin'
 | 
			
		||||
append_path '/usr/sbin'
 | 
			
		||||
append_path '/usr/bin'
 | 
			
		||||
append_path '/sbin'
 | 
			
		||||
append_path '/bin'
 | 
			
		||||
append_path '~/bin'
 | 
			
		||||
 | 
			
		||||
# Force PATH to be environment
 | 
			
		||||
export PATH
 | 
			
		||||
 | 
			
		||||
# Set IFS to be newline delimited
 | 
			
		||||
IFS="
 | 
			
		||||
"
 | 
			
		||||
export IFS
 | 
			
		||||
@@ -18,8 +39,16 @@ if test -d /etc/profile.d/; then
 | 
			
		||||
	unset profile
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Source global bash config
 | 
			
		||||
if test "$PS1" && test "$BASH" && test -r /etc/bashrc; then
 | 
			
		||||
# Unload our profile API functions
 | 
			
		||||
unset -f append_path
 | 
			
		||||
 | 
			
		||||
# Source global bash config, when interactive but not posix or sh mode
 | 
			
		||||
if test "$BASH" &&\
 | 
			
		||||
   test "$PS1" &&\
 | 
			
		||||
   test -z "$POSIXLY_CORRECT" &&\
 | 
			
		||||
   test "${0#-}" != sh &&\
 | 
			
		||||
   test -r /etc/bashrc
 | 
			
		||||
then
 | 
			
		||||
	. /etc/bashrc
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
@@ -28,5 +57,3 @@ unset TERMCAP
 | 
			
		||||
 | 
			
		||||
# Man is much better than us at figuring this out
 | 
			
		||||
unset MANPATH
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user