Thursday 5 March 2009

DEPRECIATED: Setting the hostname in gnome terminal

If you SSH to another host you might want to display the hostname of the remote host in the gnome terminal title bar

Put this code in your ~/.bashrc file;

case $TERM in
(xterm*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}($(id -ng))@${HOSTNAME}:
${PWD}\007"'
;;
esac

2 comments:

Joshua Gray said...

That does not seem to do anything for me.

I just added it to the end of .bashrc. Then I sourced the file and ssh'd to a remote host, but the title in the tab stayed the same. Am I missing something?

Brett said...

Josh

I had a look at my current machine, it seems that Karmic has a similar but different section in their bash setting s file (which is now called .bashrc.gz apparently)

Check for a section like this in that file;

# 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


I've marked this post as depreciated.