or in your:
But if, like many UNIX users, you might log in from time to time at different terminals, from home, or on different systems over a network, you need some more intelligent method for setting the terminal type.
TERM=`tset - -Q
(Given the - option, tset prints the value that it determines for the terminal type to The -Q (quiet) option causes tset to suppress printing of a message it normally prints regarding the values to which it has set the erase and kill characters - a job it does in its alternate role as terminal initializer. The surrounding the tset command cause its output to be interpolated into the command line.). Otherwise, it , but keeps the terminal type to itself.
In the C shell, you should use the
command to capture the output of tset
; this will also allow you
(You must also issue the command
To see what tset can do, consider a case where the terminal's serial line is connected to a dialup modem, through which several different users might be connected, each using a different type of terminal. Accordingly, the default terminal type in /etc/ttytype should be set to dialup . The tset command could then be used in the .login file as follows, with the appropriate terminal type set for each user:
set noglob eval `tset -s -Q -m 'dialup:vt100'`
This means that if ttytype says dialup , use vt100 as the terminal type. A colon separates the ttytype value and the value to which it is to be mapped. If a user wants to be prompted to be sure, place a question mark after the colon and before the mapped terminal type:
set noglob eval `tset -s -Q -m 'dialup:?vt100'`
The prompt will look like this:
TERM = (vt100)
If the user presses RETURN, the preferred terminal type will be used. Alternatively, another terminal type could be entered at that time.
You can cause tset to prompt for a terminal type even without testing a generic entry like dialup . Just specify the desired terminal type, preceded by a question mark, after the -m option. For example:
set noglob eval `tset -s -Q -m '?vt100'`
It is also possible to specify different terminal types for different line speeds. Say, for example, that you normally used a Wyse-50 with a 9600-bps modem when dialing in from home, but used a portable PC with a VT100 terminal emulator and 2400-bps modem when you were on the road. You might then use a tset command like this:
set noglob eval `tset -s -Q -m 'dialup@2400:vt100' wy50`
Assuming that the type is set in ttytype as dialup , tset will use the type vt100 if at 2400 bps and, if not, will use the type wy50 .
[Watch out for the linespeed switches. They don't work on a lot of networked systems - usually, the line speed at the computer's port is higher than the speed at the terminal. The same problem occurs, these days, with dialup modems that use data compression. -JP ] Various symbols can be used for line-speed calculations:
Multiple -m options can be specified; the first map to be satisfied will be used. If no match is found, a final value specified on the line without a -m option (as in the above example) will be used. If no value is specified, the type in /etc/ttytype will be used.
- from O'Reilly & Associates' termcap & terminfo , Chapter 4