# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
	# Shell is non-interactive.  Be done now!
	return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Minor errors in the spelling of a directory component in a cd command
# will be corrected.
shopt -s cdspell

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.
use_color=false
safe_term=${TERM//[^[:alnum:]]/.}	# sanitize TERM

if [[ -f /etc/DIR_COLORS ]] ; then
	grep -q "^TERM ${safe_term}" /etc/DIR_COLORS && use_color=true
elif type -p dircolors >/dev/null ; then
	if dircolors --print-database | grep -q "^TERM ${safe_term}" ; then
		use_color=true
	fi
fi

if ${use_color} ; then
	if [ "$EUID" = 0 ] || [ "`whoami`" == 'root' ]; then
		export PS1='\[\033[1;31m\]\h \[\033[1;34m\]\W \$ \[\033[00m\]'
	else
		export PS1='\[\033[1m\]\u@\h \[\033[0;31m\]\W \$ \[\033[00m\]'
	fi
else
	PS1='\u@\h: \W \$ '
fi

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term

