dots/bash/title_prompt

35 lines
777 B
Text
Raw Normal View History

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*)
2009-03-07 20:47:51 -06:00
if [ "${STY}" ] ; then
TITLEBAR='\[\033k\u@\h:\w\033\134\]'
else
TITLEBAR='\[\033]1;\u@\h:\w\007\033]2;\u@\h:\w\007\]'
fi
;;
screen*)
2009-01-20 22:24:52 -06:00
TITLEBAR='\[\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