[lug] Gnome Terminal Dynamically-set title problem

Michael J. Hammel mjhammel at graphics-muse.org
Thu Jun 30 20:12:21 MDT 2005


On Thu, 2005-06-30 at 19:45 -0600, Ferdinand Schmid wrote:
> You can configure it in the Edit Profile -> Title and Command tab to 
> "Dynamically-set title:".  However, this only works for me when I ssh into a 
> very old SuSE Linux machine.  Any of the newer machines must not return the 
> proper status to the shell because my title update fails.
> 
> So far my google searches remained fruitless.  Any ideas what I need to do get 
> this feature working?  

Most X terminals support escape sequences for this.  I've been doing it
like this for years in my .bashrc (or kshrc as the case may be):

if [ "$TERM" = "xterm" ] && [ "$0" = "bash" -o "$0" = "-bash" -o "$0" =
"/bin/bash" ]
then
   ilabel () { echo -n "^[]1;$*^G"; }
   label () { echo -n "^[]2;$*^G"; }
   cds () { "cd" $*; eval stripe; }
   vis () { eval stripe2; "vi" $*; eval stripe;}
   alias cd=cds
   alias vi=vis
   eval stripe
   # eval ilabel "$USER@$HOSTNAME"
   eval ilabel "$HOSTNAME"
fi

So when I cd into a directory, the directory gets stuffed into the
terminal title bar.  And when I vi a file, the filename gets stuffed int
he title bar (and reset when I exit vi).  Works in gnome-terminal,
xterm, rxvt, kterm, eterm, and XFCE's Terminal, plus lots of others.
The if test might need tweaking, but that should be about it.  The ^G is
a real Ctrl-G.  I can also run "label blah" at any time to put "blah" in
the title bar.

-- 
Michael J. Hammel           |   We're going to turn this team around 360 
The Graphics Muse           |   degrees.
mjhammel at graphics-muse.org  |      Jason Kidd, upon his being drafted by
http://www.graphics-muse.com       the NBA's Dallas Mavericks




More information about the LUG mailing list