Unix Programming - setting window title

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > March 2005 > setting window title





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author setting window title
junky_fellow@yahoo.co.in

2005-03-28, 7:56 am

Is there any way to set my window title equal to
my shell prompt "PS1" ?
If the "PS1" changes the (as I change directories) the
window title should also change.
I have set my PS1 to indicate hostname, present working directory
and the user name.

Thanx for any help in advance...

Måns Rullgård

2005-03-28, 7:56 am

junky_fellow@yahoo.co.in writes:

> Is there any way to set my window title equal to
> my shell prompt "PS1" ?
> If the "PS1" changes the (as I change directories) the
> window title should also change.
> I have set my PS1 to indicate hostname, present working directory
> and the user name.


Put \[\e]0;title-stuff\007\] in your PS1.

--
Måns Rullgård
mru@inprovide.com
Ulrich Eckhardt

2005-03-28, 7:56 am

junky_fellow@yahoo.co.in wrote:
> Is there any way to set my window title equal to
> my shell prompt "PS1" ?
> If the "PS1" changes the (as I change directories) the
> window title should also change.
> I have set my PS1 to indicate hostname, present working directory
> and the user name.


There is a program called xttitle and some shells have another environment
var called PROMPT_COMMAND.

BTW: you should deactivate this when not running under X, so a check for
e.g. $XAUTHORITY is in place.

All this assuming you're talking about X11 terminals, which you never said
though....

Uli

--
http://www.erlenstar.demon.co.uk/unix/
Victor Wagner

2005-03-28, 6:18 pm

Ulrich Eckhardt <doomster@knuut.de> wrote:
: junky_fellow@yahoo.co.in wrote:
: > Is there any way to set my window title equal to
: > my shell prompt "PS1" ?
: > If the "PS1" changes the (as I change directories) the
: > window title should also change.
: > I have set my PS1 to indicate hostname, present working directory
: > and the user name.
: There is a program called xttitle and some shells have another environment
: var called PROMPT_COMMAND.

This command just outputs simple escape sequence, which shell can just
as well output itself.

: BTW: you should deactivate this when not running under X, so a check for
: e.g. $XAUTHORITY is in place.

Better to check terminal type. If it is xterm* or rxvt*, then you can
use xterm-specific escape sequence.

Who have said you that thing would work only under X11?

There is for example, win32 terminal emulator putty, which support this
sequence among other xterm-specific things. It sets TERM variable to
xterm.

: All this assuming you're talking about X11 terminals, which you never said
: though....

And this is correct, because it would work under Windows too. May be it
would also work under MacOS if you find good terminal emulator for it.
If there is shell WINDOW and it have a title, somebody would write
support for this escape sequence eventually.
--
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com