xtitle not changing title in Ubuntu 11.04

Solution 1:

Turns out xtitle is working fine and changing the title. However, there's a section in the default .bashrc as follows:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

which sets the prompt up so that it changes the title back to the usual value every time it asks the user for input.

By commenting the PS1=... line above out, the title remains set to whatever you choose.

This has the side effect of not updating the current user@host status for all terminals. To selectively enable this for just the current shell, before running xtitle use:

export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

(Remember, you must source this in the terminal, not call/source from a script!)