From owner-freebsd-questions Fri Feb 6 06:40:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA20180 for questions-outgoing; Fri, 6 Feb 1998 06:40:18 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from aslan.dos.nortel.com (aslan.dos.nortel.com [192.7.1.11]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA20171 for ; Fri, 6 Feb 1998 06:40:14 -0800 (PST) (envelope-from malachai@iname.com) Received: from sunsrvr6.humb.nt.com (fireside.dos.nortel.com [192.7.1.10]) by aslan.dos.nortel.com (8.8.5/NORTEL-DOS1.0) with SMTP id JAA03482 ; Fri, 6 Feb 1998 09:44:53 -0500 (EST) Received: from sun38.cci.com by sunsrvr6.humb.nt.com (4.1/SMI-4.1) for questions@freebsd.org; id AA04049; Fri, 6 Feb 98 09:39:59 EST Received: from localhost by sun38.cci.com (4.1/SMI-4.1) id AA05195; Fri, 6 Feb 98 09:39:58 EST Date: Fri, 6 Feb 1998 09:39:57 -0500 (EST) From: Shawn Halpenny X-Sender: rsh@sun38 To: questions@FreeBSD.ORG Cc: Burton Sampley , Greg Lehey Subject: Re: Dynamic title in XTerm bound to F8 (fwd) In-Reply-To: <19980206132625.47987@freebie.lemis.com> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG X-To-Unsubscribe: mail to majordomo@FreeBSD.org "unsubscribe questions" On Fri, 6 Feb 1998, Greg Lehey wrote: > On Thu, 5 February 1998 at 18:15:01 -0800, Burton Sampley wrote: > >> > >> I don't understand why this should interest the ISPs, so I'm replying > >> only to -questions. > > > > Thanks for the help. I've been 'banging my head against a brick wall' > > trying to figure this out. I finally did figure out a solution shortly > > after submitting my request for help. > > > > The reason I think ISP's might be interested is if they manage more than > > one box using XFree86 and xterm. > > Well, sure, but that goes for just about everybody who uses xterms. I > really don't think you should be spamming -isp with this. > > > It can be quite convent to just hit 1 single key to update the xterm > > title to the hostname of the box they are currently working on, > > especially if they need to minimize more than one xterm (ie, if > > you're changing DNS entries on more than one DNS server). > > It would be a lot more convenient to have it happen automatically. > Here's my cd script (bash): > > cd () > { > command cd $* > xtset -t "%u (%T) %H:%D" > xtset -i "%u@%H:%D" > } > > This sets different strings for the title bar (longer) and the icon > (shorter). > > > The solution is: > > > >> /.Xdefaults: > > xterm*VT100.translations: #override\ > > NoneF8: string("echo \\"^V^[]0;`hostname`^V^G\\"") \ > > string(0x0d) \n\ > > > > In the above string, "^V^[" is produced with the following key sequence in > > vi "ctrl-v ctrl-v ctrl-v esc" and "^G" is produced with "ctrl-v ctrl-g". > > The \\ correctly escapes the inside set of double quotes. NOTE: I've > > only tried this with csh and derivatives (ie, tcsh) on both ends. > > > > NOTE: For whoever's interested, in the command above, 0 specifies the > > regular title and the minimized title; 2 will change only the regular > > title and 1 will change only the minimized title. > > > > I verified this works by ssh'ing into several remote accounts and pressing > > F8. It did what I wanted it to do. > > Sure, but it requires you to hit a key, and it takes away any other > purpose that this key might have. > > Greg > 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. -- Shawn Halpenny