[RHCE] xterm title bar
Frank Pittenger
rhce@trilug.org
Fri, 23 Aug 2002 10:56:00 -0400 (EDT)
John,
Yes, this is the basic control sequence. I was trying to write up something
which would work in a variety of shells. I use tcsh for my personal shell
and the solution is very simple. I can just put this in my ~/.cshrc file
and it does it all (this does not work in other shells, not even csh):
set prompt="%{\033]0;%n@%M %~%L\007%}%n\[%h\]> "
This does it all in tcsh. Any time you change directory, the prompt will
update, and when it does, it pushes the current path into the xterm title.
This part of the command:
%{\033]0;%n@%M %~%L\007%}
pushes "username@hostname path" into the titlebar.
This part:
%n\[%h\]>
makes my prompt:
"username[shell history number] > "
I used to do this in my ~/.cshrc for csh:
alias settitle 'printf "\033]0;`whoami`@${HOST} ${cwd}\007"'
settitle
alias cd 'cd \!*;dirs;settitle'
alias pushd 'pushd \!*;settitle'
alias popd 'popd \!*;settitle'
I'm sure these approaches can be easily adapted to other shells.
Frank
On 23-Aug-02 at 10:23, John F Davis (johndavi@us.ibm.com) wrote:
> Hello
>
> I thoughly enjoyed the X11 talk. I'm still waitng for the xterm prompt tip
> in PS1 to make it to this list..
>
> While we are waiting, here is a script I use to something similar.
>
> #title.sh
> echo -ne "\033]0; $1 \007"
>
> I use it like this: title.sh build
> and it will set the title bar of the current xterm to build
> and in a different xterm title.sh debug and it sets the title to debug.
>
> Thus, its easier to pick your window when you have a bunch of icons to
> choose from.
>
> Also, there is a way to do this automatically in your PS1 prompt, so you
> can move about the filesytem and it updates your
> title bar based upon your path. (That's what we are waiting for right?)
> Once we get the PS1 script to do this, I am sure it
> can be modified to prepend it with some info set by a script.
>
> ie. Build: ~/sandbox/v0802/src and
> Debug: ~/sandbox/v0802/exe
>
> yada yada yada
>
> JD
>
>
> _______________________________________________
> RHCE@trilug.org Mailing list
> http://www.trilug.org/mailman/listinfo/rhce
> Archives for the RHCE list:
> http://www.trilug.org/pipermail/rhce