This is what I have done on the screen server to achieve dynamic title. in .bashrc :
PROMPT_COMMAND='if [ $TERM = "screen" ]; then printf "\033k${HOSTNAME%%.*}\033\\" ; fi' in .ssh/config : # this won't work unless your screen server has openssh 5.1 or above host * PermitLocalCommand yes LocalCommand /path/to/screen_ssh.sh %n in screen_ssh.sh : # got the idea from http://www.tenshu.net/screen_ssh/ if [ $TERM = "screen" ]; then printf "\033k${1%%.*}\033\\" ; fi Also I got my concept cleared from #screen and #bash irc channel in irc.freenode.net Now when I ssh to a host it changes the window title to match the hostname. And as soon as I logout it changes back to the screen server's hostname In other words window title always has the correct hostname of the screen window I am on Thanks to all On Mon, Jun 1, 2009 at 2:49 AM, Michael Grant <mgr...@grant.org> wrote: > On Mon, Jun 1, 2009 at 05:47, Asif Iqbal <vad...@gmail.com> wrote: >> On Thu, May 28, 2009 at 5:25 PM, Alan Young <alansyoung...@gmail.com> wrote: >>> On Wed, May 27, 2009 at 20:17, Asif Iqbal <vad...@gmail.com> wrote: >>>> How do I change the title of a screen window (tab) dynamically, to >>>> match the hostname I ssh to ? > > I do this as follows: > > in .screenrc: hardstatus lastline > > in .bashrc: export PS1='[\$\!] \[ESC_\H \wESC\\\]' > where ESC is an escape character. > > This makes my prompt look like [$123] and puts the machine name and > current working dir in the status line. It also (at least on windows) > puts the machine named into the title bar of the window. > > You need the \[ and \] to tell bash not to count those characters as > being displayed on the line, otherwise, it messes up the display when > you start wrapping long input lines. > > ESC_ gets you into the status line and ESC\ gets out out. > > Is that what you're looking for? > > Michael Grant > -- Asif Iqbal PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? _______________________________________________ screen-users mailing list screen-users@gnu.org http://lists.gnu.org/mailman/listinfo/screen-users