dots/bash/title_prompt
2009-01-16 14:38:56 -05:00

30 lines
647 B
Text
Executable file

function do_prompt ()
{
if [ $? -ne 0 ] ; then
local ERROR_PROMPT="\[\033[01;31m\]"
fi
local BASE
if [ $UID -ne 0 ] ; then
BASE="$"
else
BASE="#"
fi
local TITLEBAR
case $TERM in
xterm*|*rxvt*|cygwin|interix|Eterm|mlterm|kterm|aterm|putty*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
screen*)
TITLEBAR='\[\033k\033\134\033k\u@\h:\w\033\134\]'
;;
*)
TITLEBAR=''
;;
esac
PS1="${TITLEBAR}\[\033[01;32m\]\u@\h \[\033[01;34m\]\w ${ERROR_PROMPT}${BASE} \[\033[00m\]"
export PS1
}
PROMPT_COMMAND=do_prompt