Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Feb 1998 10:22:21 -0800 (PST)
From:      Studded <Studded@dal.net>
To:        Shawn Halpenny <malachai@iname.com>
Cc:        questions@FreeBSD.ORG, Burton Sampley <bsampley@slip.net>, Greg Lehey <grog@lemis.com>
Subject:   Re: Dynamic title in XTerm bound to F8 (fwd)
Message-ID:  <Pine.BSF.3.96.980208101048.20485A-100000@dt051n19.san.rr.com>
In-Reply-To: <Pine.SUN.3.96.980206093715.5160C-100000@sun38>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 6 Feb 1998, Shawn Halpenny wrote:

> As a side note, those people who use a recent version of bash can
> insert this string directly into their prompt.  I've found this
> especially handy when rsh'ing between many hosts and having my xterm
> title change to represent my current host no matter what box I'm on. 
> Doesn't involve any extra key presses and doesn't involve aliasing
> commands.  I know it does not work with bash versions < 1.14.6, and
> that it does work with at least version 2.01.1.
>  
> As an example:
>  
> export PS1="\[^[]2;$USER@$HOST^G\]\u@\h:\w\$ "
>  
> The "\[" and "\]" are necessary to prevent bash from taking the
> string in between them and using it to calculate the wrap column for
> the current line (without them, bash thinks your prompt is much
> longer than it actually appears).  The stuff between them sets the
> xterm title.  The stuff after the "\]" is your favorite prompt. 
> Remember that the "^[" and the "^G" are the escape and bell
> characters, respectively.  

	I was very very excited to hear this news since I bounce around to
a lot of sites in my day-to-day work. I took this info and the source to
Greg's program and came up with this, which sets both the titlebar of the
xterm window and the title of the icon (when it's minimized) in afterstep.
I am assuming that it would work for other wm's too.  I'm also using Bash
2.01.01 in case that matters to someone.

PS1='[\u@ME \w]\n \#\$ '; export PS1

if [ $TERM = xterm ]; then
export PS1="\[^[]1;My Desk^G^[]2;$USER@$HOSTNAME^G\][\u@ME \w]\n \#\$ "
fi

	The first bit (^[]1;My Desk^G) sets the title of the icon. The
next bit sets the titlebar of the window. I used $HOSTNAME because $HOST
didn't work for me. To make the ^[ and ^G characters, you have to edit
your .bash_profile in vi, and hold down ^V (Ctrl-V) first, then continue
to hold down Ctrl and push [ or G. It may be possible to do it in pico,
but I didn't spend any time trying to figure it out. :)

	Of course, in order to make it work for remote hosts, you have to
duplicate the same process in the .bash_profile on those hosts, putting
appropriate names for the icon and such in there. 

	Once again, huge thanks to Shawn and Greg for helping me cross one
of my oldest "Things I really want to get working someday" projects off my
list. 

Doug

--
***         Chief Operations Officer, DALnet IRC network       ***
*** Proud operator, designer and maintainer of the world's largest
*** Internet Relay Chat server.  5,328 clients and still growing.
*** Try spider.dal.net on ports 6662-4    (Powered by FreeBSD)


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.980208101048.20485A-100000>