~ uncon /.bashrc

# .bashrc  1.5 (2008-04-02)
# uncon (uncon@uncon.net)

# if not running interactively, don't do anything
[ -z "$PS1" ] && return

# source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# set environment variables
export USER=`id -un`
export HOSTNAME=`/bin/hostname`

# don't put duplicate lines and same sucessive entries in the history.
export HISTCONTROL=ignoreboth

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

# enable color support of ls
if [ "$TERM" != "dumb" ]; then
    case $OSTYPE in
        linux*)
            eval "`dircolors -b`"
            alias ls='ls --color=auto'
        ;;
        freebsd*)
            export CLICOLOR=1
        ;;
        *)
        ;;
    esac
fi

# set some aliases
case $OSTYPE in
    linux*)
        alias dff="df -h -x tmpfs -x usbfs -x devfs"
        alias psf="ps xaSo pid,user,pcpu,size,command --sort pcpu"
    ;;
    freebsd*)
        alias dff="df -h -t nodevfs" 
        alias psf="ps xaSro pid,user,pcpu,vsize,command"
        alias updatedb="/usr/libexec/locate.updatedb"
        alias updateports="portsnap fetch ; portsnap update"
    ;;
    darwin*)
        alias dff="df -h -t novolfs,fdesc,devfs"
        alias psf="ps xaSro pid,user,pcpu,vsize,command"
    ;;
    *)
    ;;
esac
alias duf="du -h"
alias sc="screen -D -R"
alias cl="cd ; clear"
alias lo="clear ; logout"

# enable programmable completion features 
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

# termwide prompt originally by Giles
# much has been modified

function prompt_command {

TERMWIDTH=${COLUMNS}-1

#   Calculate the width of the prompt:

hostnam=$(echo -n $HOSTNAME | sed -e "s/[\.].*//")
#   "whoami" and "pwd" include a trailing newline
usernam=$(whoami)
cur_tty=$(tty | sed -e "s:/dev/::")
newPWD=$(echo $PWD | sed -e "s:"$HOME":~:")
#   Add all the accessories below ...
let promptsize=$(echo -n "--(${usernam}@${hostnam}:${cur_tty})----(${newPWD})--" \
                 | wc -c | tr -d " ")
let fillsize=${TERMWIDTH}-${promptsize}
fill=""
while [ "$fillsize" -gt "0" ] 
do 
    fill="${fill} "
	let fillsize=${fillsize}-1
done

if [ "$fillsize" -lt "0" ]
then
   let cut=3-${fillsize}
	newPWD="...$(echo -n $newPWD | sed -e "s/\(^.\{$cut\}\)\(.*\)/\2/")"
fi
}

PROMPT_COMMAND=prompt_command

function twtty {

# default colors
local COLOR1="\[\033[1;30m\]"
local COLOR2="\[\033[0;37m\]"
local COLOR3="\[\033[1;36m\]"
local COLOR4="\[\033[1;30m\]"
local COLOR5="\[\033[0;36m\]"
local COLOR6="\[\033[0m\]"

# brighter colors
#local COLOR3="\[\033[1;36m\]"
#local COLOR4="\[\033[0;36m\]"
#local COLOR5="\[\033[1;36m\]"

case $TERM in
    xterm*)
        TITLEBAR='\[\033]0;\u@\h:\w\007\]'
        ;;
    *)
        TITLEBAR=""
        ;;
esac

PS1="$TITLEBAR\
$COLOR5-$COLOR4-(\
$COLOR5\$usernam$COLOR4@$COLOR5\$hostnam$COLOR4:$COLOR5\$cur_tty\
${COLOR4})-${COLOR5}-\${fill}${COLOR5}-${COLOR4}-(\
$COLOR5\${newPWD}\
$COLOR4)-$COLOR5-\
\n\
$COLOR5-$COLOR4-(\
$COLOR5\$(date +%Y.%m.%d)$COLOR4:$COLOR5\$(date +%H:%M)\
$COLOR4:$COLOR3\$$COLOR4)-\
$COLOR5-\
$COLOR6 " 

PS2="$COLOR4-$COLOR5-$COLOR5-$COLOR6 "

}

case $TERM in
    linux*|cons25*|xterm*|rxvt*|screen*|vt100*)
        twtty
        ;;
    *)
        ;;
esac