##
##  @l_prefix@/etc/bash/profile -- Global Bash Profile
##

#   welcome and goodbye message ;)
echo "$HOSTNAME: user $USER, login at `date`"
trap 'echo "$HOSTNAME: user $USER, logout at `date`"' 0

#   initially adjust $PWD to symbolic path
cd $HOME

#   provide user and host information in default prompt
PS1="\u@\h\$ "

#   session timeout
export TMOUT=3600

#   environment permissions
umask 022
ulimit -c 16384
if expr $- : ".*i.*" >/dev/null; then
    mesg y
fi

#   history functionality
shopt -s histappend
HISTSIZE=100
HISTFILESIZE=100
alias h='history | $PAGER'

#   various additional variables
export TMPDIR=/tmp
export TEMPDIR=$TMPDIR
export BLOCKSIZE=1024

#   convinient root priviledge switching
root () {
    if [ $# -eq 0 -o ".$1" = ".-i" ]; then
        ssh -t -x root@localhost cd $PWD \&\& exec ${SHELL-/bin/sh}
    elif [ ".$1" = ".-l" ]; then
        ssh -x root@localhost cd $PWD \&\& `history | tail -2 | head -1 | cut -c8-`
    elif [ ".$1" = ".-t" ]; then
        shift
        ssh -t -x root@localhost cd $PWD \&\& "$@"
    else
        ssh -x root@localhost cd $PWD \&\& "$@"
    fi
}

#   suck in the Bourne-Shell environment of all OpenPKG packages
eval `@l_prefix@/etc/rc -p all env:sh`

#   path to user environment init script
if [ -f "$HOME/.bashrc" ]; then
    BASH_ENV=$HOME/.bashrc
    . $BASH_ENV
fi

