clearing the terminal screen

Leo de Wit leo at philmds.UUCP
Fri Dec 16 22:11:16 AEST 1988


In article <7007 at batcomputer.tn.cornell.edu> lynch at batcomputer.tn.cornell.edu (Tim Lynch) writes:
|
|I'm having a problem setting an environmental variable to speed up
|screen clearing. If I'm working from a hp terminal the following works:
|
|  % setenv CLEAR `clear`
|  % echo $CLEAR            # (and the screen is cleared)
|
|But, if I'm working from a vt100, issuing echo $CLEAR does nothing.
Neither does it in my environment; CLEAR appears to be an empty string.
This has possibly something to do with the special treatment of the
escape character (which is part of the sequence output by clear) by the
Cshell; the following worked fine in the Bourne shell:

$ CLEAR=`clear`
$ echo $CLEAR

|Furthermore, echo $CLEAR | wc shows that CLEAR is of length zero.
|The terminfo for the vt100 appears ok because I can issue:
|
|  % clear
|
|and the vt100 screen clears!  Actually, I don't have to change terminals;
|if I have TERM set to hp, then CLEAR is set to the correct escape sequence
|to clear the screen, whereas if TERM is set to vt100, CLEAR is not set
|to anything.  I've tried this on two different Unix machines.
|
|Anybody have a clue as to why I can't set CLEAR when TERM is equal to
|vt100?

The following works in the Cshell:

% set CLEAR="`clear`"
% alias cls 'echo "$CLEAR"'

and now you can do

% cls

to clear your terminal screen (only from the inside 8-).  The double
quotes prevent the Cshell from interpreting characters within the
string. Hope this clears things a bit 8-).

          Leo.



More information about the Comp.unix.questions mailing list