# remote hostname in terminal title bar?



## henksmets (Aug 21, 2002)

Does anyone knows how I can put the hostname of the remote host in the terminals title bar?  Or change the color of the terminal background?

I often connect to more than one remote server an i would be very handy to see immediatly wich terminal window is connected to wich server.


----------



## fddi1 (Aug 21, 2002)

shift-cmd-t to set the title in a terminal window


----------



## henksmets (Aug 23, 2002)

thanks a lot both

now i get the hostname in the titlebar, but, it doesn't changes when I login onto a remote server.  

I can get the proper server in the titlebar when using the New Command in the File menu, but i rather do it from the CL

nice intro BTW: http://www.oreilly.com/catalog/lunixmacosx/chapter/ch04.html


----------



## lanceo (Aug 23, 2002)

Henksmets,

Do get this to work when logging into a remote server, you need to add that same prompt to the .cshrc or .tcshrc file in your home directory on that remote server. Then it will work.


----------



## jpblock (Aug 23, 2002)

If you're using bash for a shell now that it ships with Jag, add the following lines to ~/.bash_profile and it will update your Terminal title bar, in addition to your shell prompt.

# add me to ~/.bash_profile
# start here
PS1='[\u@\h:\w]\$ '
export TITLEBAR='\[\033]0;\u@\h:\w \007\]'

# Terminal sets TERM_PROGRAM so we can tell it apart from regular VT100
case "$TERM_PROGRAM" in
        "Apple_Terminal")PS1="$TITLEBAR$PS1"
esac
case "$TERM" in
        "xterm")PS1="$TITLEBAR$PS1"
esac
# end insert

I've been using variants of this on other unixes for many years, and unfortunately lost track of the original author.

jpb


----------

