[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic Title

From: Asif Iqbal
Subject: Re: Dynamic Title
Date: Tue, 2 Jun 2009 16:30:00 -0400

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/ %n

in :
# got the idea from
if [ $TERM = "screen" ]; then printf "\033k${1%%.*}\033\\" ; fi

Also I got my concept cleared from #screen and #bash irc channel in

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 <address@hidden> wrote:
> On Mon, Jun 1, 2009 at 05:47, Asif Iqbal <address@hidden> wrote:
>> On Thu, May 28, 2009 at 5:25 PM, Alan Young <address@hidden> wrote:
>>> On Wed, May 27, 2009 at 20:17, Asif Iqbal <address@hidden> 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:
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]