[lug] Gnome Terminal Dynamically-set title problem

Ferdinand Schmid fschmid at archenergy.com
Fri Jul 1 10:45:33 MDT 2005


On Friday 01 July 2005 09:46, Ron Wright wrote:
> On 6/30/05, Michael J. Hammel <mjhammel at graphics-muse.org> wrote:
> > 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
>
> If you have bash, then this is a cleaner way:
>
> host=$(uname -n)
> if [ "${TERM}" = "xterm" -o "${TERM}" = "xterm-color" ]
> then
>    if [ -z "${BASH}" ]
>    then
>       echo "\033]2;${host}\007\033]1;${host}\007"
>    else
>       export PROMPT_COMMAND=\
>       'echo -ne "\033]2;${host}:${PWD}\007\033]1;@${host}:${PWD}\007"'
>    fi
> fi
>
> Also, for VIM just add "set title" to your .vimrc.  Bash with the
> PROMPT_COMMAND set as above will set it back when you exit.
>
<snip>
Perfect - thank you very much!  I am not bash skilled enough to find out why 
Michael's version didn't work.  It was missing the stripe alias - but I found 
that thanks to google.  However, the version of his prompt command didn't 
work for me - it just printed the command before my system prompt.

This solution works perfectly, including the vi part.  I love it!!!

Thanks again to everybody, your responses were fast and very educational.  I 
hope this thread will be useful to others...
Ferdinand

-- 
Ferdinand Schmid
Architectural Energy Corporation
Celebrating over 20 Years of Improving Building Energy Performance
http://www.archenergy.com




More information about the LUG mailing list