xterm understands these nifty ANSI escape characters in the PROMPT_COMMAND environment variable. The variable below is evaluated each time the prompt returns:
# If this is an xterm, set the title to user@host:dir
case $TERM in
xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
;;
*)
;;
esac