start page | rating of books | rating of authors | reviews | copyrights

Unix Power ToolsUnix Power ToolsSearch this book

3.17. Terminal Setup: Setting and Testing Window Name

I use several xterm windows. Here's an excerpt from my X setup file (Section 3.20):

WINNAME=console xterm -C -title Console -geometry 80x9+0+0 &
WINNAME=work xterm -title "work xterm" -geometry 80x74+329-81 &

The WINNAME=name sets an environment variable named WINNAME for the particular command line it's on. This is passed through the environment, through the xterm process, to the shell running inside the window. So the shell's setup file can test for this variable -- and, by knowing the window name stored in that variable, do specific setup for just that window. For example, in tcsh:

-fSection 11.10, { }Section 28.4

if ($?WINNAME) then
    switch ($WINNAME)
    case console:
        # Watch logs:
        tail -f /var/log/{messages,maillog,secure} ~/tmp/startx.log &
        breaksw
    case work:
        /usr/games/fortune
        fetchmail
        breaksw
    endsw
endif

On the console terminal, this .tcshrc file starts a job in the background (Section 23.2) to watch log files. On the work xterm, I get a fortune and grab email from the POP server.

--JP and SJC



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.