#!/bin/bash
# Begin /etc/profile

source /etc/profile.d/0path-functions.sh

# Set the initial path
export PATH=/usr/bin
if [ $EUID -eq 0 ] ; then
        pathappend /usr/sbin
        if [ ! -L /sbin ]; then
                pathappend /sbin
        fi
        unset HISTFILE
fi

if [[ "$TERM" = linux ]]; then
  export LANG=C.UTF-8
else
  source /etc/locale.conf
  for i in $(locale); do
    key=${i%=*}
    if [[ -v $key ]]; then
      export $key
    fi
  done
fi

# Set up some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"

# Set some defaults for graphical systems
export XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/share}
export XDG_CONFIG_DIRS=${XDG_CONFIG_DIRS:-/etc/xdg}
export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp/xdg-$USER}

# Set up a red prompt for root and a green one for users.
NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
YELLOW="\[\e[1;33m\]"
ECODE='($?)'

if [[ ! /proc/1/root/. -ef / ]]; then
  CHROOT='(chroot)'
fi

if [[ $EUID == 0 ]] ; then
  PS1="${YELLOW}${CHROOT}${ECODE}${RED}\u [ ${NORMAL}\w${RED} ]# ${NORMAL}"
else
  PS1="${YELLOW}${CHROOT}${GREEN}\u [ ${NORMAL}\w${GREEN} ]\$ ${NORMAL}"
fi

for script in /etc/profile.d/*.sh ; do
        if [ -r $script ] ; then
                . $script
        fi
done

unset script ECODE CHROOT RED GREEN NORMAL YELLOW

# End /etc/profile
