date and time created 91/12/22 18:54:52 by bostic
[unix-history] / usr / src / usr.bin / tset / tset.1
CommitLineData
b5dc1377 1.\" Copyright (c) 1985, 1990 The Regents of the University of California.
2088f2bf 2.\" All rights reserved.
2bcbe3d6 3.\"
263cc8fc 4.\" %sccs.include.redist.roff%
2088f2bf 5.\"
263cc8fc 6.\" @(#)tset.1 6.7 (Berkeley) %G%
2bcbe3d6 7.\"
b5dc1377
CL
8.Dd
9.Dt TSET 1
10.Os BSD 4
11.Sh NAME
12.Nm tset
13.Nd terminal dependent initialization
14.Sh SYNOPSIS
15.Nm tset
16.Op Ar options
263cc8fc 17.Oo
b5dc1377 18.Fl m
263cc8fc
CL
19.Oo
20.Ar ident
21.Oc Ns Oo
22.Ar test baudrate
23.Oc Ns Cm \&: Ns Ar type
24.Oc ...
25.Op type
b5dc1377
CL
26.Nm reset
27.Op Ar options
263cc8fc 28.Oo
b5dc1377 29.Fl m
263cc8fc
CL
30.Oo
31.Ar ident
32.Oc Ns Oo
33.Ar test baudrate
34.Oc Ns Cm \&: Ns Ar type
35.Oc ...
36.Op type
b5dc1377
CL
37.Sh DESCRIPTION
38.Nm Tset
263cc8fc
CL
39sets up your terminal when you first log in to a
40.Tn UNIX
41system.
52309911 42It does terminal dependent processing such as setting
2bcbe3d6 43erase and kill characters, setting or resetting delays,
52309911 44sending any sequences needed to properly initialized the terminal,
2bcbe3d6
KM
45and the like.
46It first determines the
b5dc1377 47.Ar type
52309911
KM
48of terminal involved,
49and then does necessary initializations and mode settings.
b5dc1377 50The type of terminal attached to each
263cc8fc 51.Tn UNIX
b5dc1377
CL
52port is specified in the
53.Xr ttys 5
52309911
KM
54database.
55Type names for terminals may be found in the
b5dc1377 56.Xr termcap 5
52309911
KM
57database.
58If a port is not wired permanently to a specific terminal (not hardwired)
59it will be given an appropriate generic identifier such as
263cc8fc 60.Em dialup .
b5dc1377 61.Pp
52309911 62In the case where no arguments are specified,
b5dc1377
CL
63.Nm tset
64simply reads the terminal type out of the environment variable
65.Ev TERM
263cc8fc
CL
66and re-initializes the terminal.
67The rest of this manual concerns
52309911
KM
68itself with mode and environment initialization,
69typically done once at login, and options
2bcbe3d6
KM
70used at initialization time to determine the terminal type and set up
71terminal modes.
b5dc1377 72.Pp
263cc8fc
CL
73.Bl -tag -width flag
74.It Fl e Ns Ar c
b5dc1377
CL
75set the erase character to be the named character
76.Ar c
77on all terminals,
78the default being the backspace character on the terminal, usually ^H.
79The character
80.Ar c
81can either be typed directly, or entered using the hat
82notation used here.
263cc8fc 83.It Fl k Ns Ar c
b5dc1377
CL
84is similar to
85.Fl e
86but for the line kill character rather than the erase character;
87.Ar c
88defaults to ^X (for purely historical reasons).
89The kill characters is left alone if
90.Fl k
91is not specified.
92The hat notation can also be used for this option.
263cc8fc 93.It Fl i Ns Ar c
b5dc1377
CL
94is similar to
95.Fl e
96but for the interrupt character rather than the erase character;
97.Ar c
263cc8fc
CL
98defaults to ^C.
99The hat notation can also be used for this option.
100.It Fl
b5dc1377
CL
101The name of the terminal finally decided upon is output on the
102standard output.
103This is intended to be captured by the shell and placed in the
104environment variable
105.Ev TERM.
263cc8fc 106.It Fl s
b5dc1377
CL
107Print the sequence of
108.Xr csh 1
109commands to initialize the environment variables
110.Ev TERM
111and
112.Ev TERMCAP
113based on
114the name of the terminal finally decided upon.
263cc8fc 115.It Fl m
b5dc1377
CL
116The
117.FL m
118Specify what terminal type to use on specific ports (i.e. map the
119terminal type to a port as found in
120.Xr ttys 5 . )
121See below.
263cc8fc
CL
122.It Fl n
123On systems with the
124.Bx 4
125driver,
b5dc1377
CL
126specifies that the new tty driver modes should be initialized for this terminal.
127For a
263cc8fc 128.Tn CRT ,
b5dc1377 129the
263cc8fc 130.Dv CRTERASE
b5dc1377 131and
263cc8fc 132.Dv CRTKILL
b5dc1377
CL
133modes are set only if the baud rate is 1200 or greater.
134See
135.Xr tty 4
136for more detail.
263cc8fc 137.It Fl I
b5dc1377 138suppresses transmitting terminal initialization strings.
263cc8fc 139.It Fl Q
b5dc1377 140suppresses printing the
263cc8fc 141.Dq Li "Erase set to"
b5dc1377 142and
263cc8fc 143.Dq Li "Kill set to"
b5dc1377 144messages.
263cc8fc 145.El
b5dc1377 146.Pp
5325ced3 147When used in a startup script
263cc8fc 148.Pf ( Pa .profile
b5dc1377
CL
149for
150.Xr sh 1
52309911 151users or
263cc8fc 152.Pa .login
52309911 153for
263cc8fc 154.Xr csh 1
52309911
KM
155users) it is desirable to give information about the type of terminal
156you will usually use on ports which are not hardwired.
157These ports are identified in
b5dc1377 158.Xr ttys 5
52309911 159as
b5dc1377 160.Li dialup
2bcbe3d6 161or
b5dc1377 162.Li plugboard
2bcbe3d6 163or
b5dc1377 164.Li arpanet ,
2bcbe3d6
KM
165etc.
166To specify
52309911 167what terminal type you usually use on these ports, the
b5dc1377 168.Fl m
52309911
KM
169(map) option flag is followed by the appropriate port type identifier,
170an optional baud rate specification,
171and the terminal type.
172(The effect is to ``map'' from some conditions to a terminal type,
173that is, to tell
b5dc1377 174.Nm tset
52309911 175``If I'm on this kind of port, guess that I'm on that kind of terminal''.)
2bcbe3d6 176If more than one mapping is specified, the first applicable mapping prevails.
52309911
KM
177A missing port type identifier matches all identifiers.
178Any of the alternate generic names given in
b5dc1377 179.Xr termcap 5
52309911 180may be used for the identifier.
b5dc1377 181.Pp
52309911 182A
b5dc1377 183.Ar baudrate
52309911 184is specified as with
263cc8fc 185.Xr stty 1 ,
52309911
KM
186and is compared with the
187speed of the diagnostic output (which should be the control terminal).
188The baud rate
b5dc1377 189.Ar test
52309911 190may be any combination of:
263cc8fc
CL
191.Cm \&> ,
192.Cm \&@ ,
193.Cm \&< ,
2bcbe3d6 194and
263cc8fc
CL
195.Cm \&! ;
196.Cm \&@
52309911 197means ``at''
2bcbe3d6 198and
263cc8fc
CL
199.Cm \&!
200inverts the sense of the test.
201To avoid problems with metacharacters, it
2bcbe3d6 202is best to place the entire argument to
b5dc1377 203.Fl m
2bcbe3d6 204within ``\''' characters; users of
b5dc1377 205.Xr csh 1
2bcbe3d6 206must also put a ``\e'' before any ``!'' used here.
263cc8fc 207.Bd -filled -offset indent
52309911 208tset \-m \'dialup>300:adm3a\' -m dialup:dw2 -m \'plugboard:?adm3a\'
263cc8fc 209.Ed
b5dc1377 210.Pp
2bcbe3d6 211causes the terminal type to be set to an
b5dc1377 212.Ar adm3a
2bcbe3d6 213if the port in use is a dialup at a speed greater than 300 baud;
b5dc1377
CL
214to a
215.Ar dw2
2bcbe3d6 216if the port is (otherwise) a dialup (i.e. at 300 baud or less).
263cc8fc 217.Sy NOTE :
b5dc1377 218the examples given here appear to take up more than
263cc8fc
CL
219one line, for text processing reasons.
220When you type in real
b5dc1377
CL
221.Nm tset
222commands, you must enter them entirely on one line.
2bcbe3d6 223If the
b5dc1377 224.Ar type
52309911 225finally determined by
b5dc1377 226.Nm tset
52309911 227begins with a question mark,
2bcbe3d6
KM
228the user is asked if s/he really wants that type.
229A null response means to use that type;
230otherwise, another type can be entered which will be used instead.
52309911
KM
231Thus, in the above case, the user will be queried on a plugboard port
232as to whether they are actually using an
263cc8fc 233.Ar adm3a .
b5dc1377 234.Pp
52309911 235If no mapping applies and a final
b5dc1377 236.Ar type
52309911 237option, not preceded by a
b5dc1377 238.Fl m ,
52309911
KM
239is given on the command line
240then that type is used;
ad2558a8 241otherwise the type found in the
b5dc1377 242.Xr ttys 5
52309911
KM
243database will be taken to be the terminal type.
244This should always be the case for hardwired ports.
b5dc1377 245.Pp
52309911 246It is usually desirable to return the terminal type, as finally determined by
b5dc1377 247.Nm tset ,
52309911 248and information about the terminal's capabilities
263cc8fc
CL
249to a shell's environment.
250This can be done using the
b5dc1377 251.Fl
2bcbe3d6 252option; using the Bourne shell,
263cc8fc
CL
253.Xr \&sh 1 :
254.Bd -literal -offset indent
255export TERM; TERM=\`tset options ... \`
256.Ed
b5dc1377 257.Pp
2bcbe3d6 258or using the C shell,
b5dc1377 259.Xr csh 1 :
263cc8fc
CL
260.Bd -literal -offset indent
261setenv TERM \`tset \- options ... \`
262.Ed
b5dc1377 263.Pp
52309911 264With
b5dc1377 265.Xr csh 1
263cc8fc
CL
266it is preferable to use the following command in one's
267.Pa .login
268file to
b5dc1377
CL
269initialize the
270.Ev TERM
271and
272.Ev TERMCAP
273environment variables at the same time.
263cc8fc
CL
274.Bd -literal -offset indent
275eval \`tset -s options ... \`
276.Ed
b5dc1377 277.Pp
ad2558a8 278It is also convenient to make an alias in your .cshrc:
263cc8fc
CL
279.Bd -literal -offset indent
280alias tset \'eval \`tset \-s \e!*\`\'
281.Ed
b5dc1377 282.Pp
ad2558a8 283This allows the command:
b5dc1377
CL
284.Pp
285.Dl tset 2621
286.Pp
ad2558a8 287to be invoked at any time to set the terminal and environment.
b5dc1377 288.Sy Note to Bourne Shell users:
52309911 289It is
b5dc1377 290.Em not
52309911
KM
291possible to get this aliasing effect with a shell script,
292because shell scripts cannot set the environment of their parent.
293(If a process could set its parent's environment,
294none of this nonsense would be necessary in the first place.)
b5dc1377 295.Pp
2bcbe3d6 296These commands cause
b5dc1377 297.Nm tset
52309911 298to place the name of your terminal in the variable
b5dc1377
CL
299.Ev TERM
300in the environment; see
301.Xr environ 7 .
302.Pp
2bcbe3d6 303Once the terminal type is known,
b5dc1377 304.Nm tset
52309911 305engages in terminal driver mode setting.
2bcbe3d6 306This normally involves sending an initialization sequence to the
52309911
KM
307terminal, setting the single character erase (and optionally
308the line-kill (full line erase)) characters,
309and setting special character delays.
310Tab and newline expansion are turned off during transmission of
311the terminal initialization sequence.
b5dc1377 312.Pp
2bcbe3d6 313On terminals that can backspace but not overstrike
b5dc1377 314(such as a
263cc8fc 315.Tn CRT ) ,
2bcbe3d6
KM
316and when the erase character is the default erase character
317(`#' on standard systems),
b5dc1377 318the erase character is changed to
263cc8fc 319.Dv BACKSPACE
b5dc1377
CL
320(Control-H).
321.Pp
52309911 322If
b5dc1377 323.Nm tset
52309911 324is invoked as
b5dc1377 325.Nm reset ,
52309911
KM
326it will set cooked and echo modes, turn off cbreak and raw modes,
327turn on newline translation, and restore special characters
328to a sensible state before any terminal dependent processing is done.
b5dc1377 329Any special character that is found to be
263cc8fc
CL
330.Tn NULL
331or ``\-1'' is reset to its default value.
332All arguments to
b5dc1377 333.Nm tset
641c43e1 334may be used with reset.
b5dc1377 335.Pp
52309911 336This is most useful after a program dies leaving a terminal in a funny
263cc8fc
CL
337state.
338You may have to type
b5dc1377
CL
339.Dq Li <LF>reset<LF>
340to get it to work
341since
342.Li <CR>
263cc8fc
CL
343may not work in this state.
344Often none of this will echo.
b5dc1377
CL
345.Sh EXAMPLES
346.Pp
347These examples all assume the Bourne shell and use the
348.Fl
349option.
52309911 350If you use
b5dc1377 351.Xr csh ,
52309911
KM
352use one of the variations described above.
353Note that a typical use of
b5dc1377
CL
354.Nm tset
355in a
263cc8fc
CL
356.Pa .profile
357or
b5dc1377
CL
358.Pa .login
359will also use the
360.Fl e
52309911 361and
b5dc1377 362.Fl k
52309911 363options, and often the
b5dc1377 364.Fl n
52309911 365or
b5dc1377 366.Fl Q
52309911
KM
367options as well.
368These options have not been included here to keep the examples small.
b5dc1377
CL
369.Sy NOTE :
370some of the examples given here appear to take up more than
263cc8fc
CL
371one line, for text processing reasons.
372When you type in real
b5dc1377
CL
373.Nm tset
374commands, you must enter them entirely on one line.
375.Pp
376At the moment, you are on a
377.Li 2621 .
52309911 378This is suitable for typing by hand but
b5dc1377
CL
379not for a
380.Pa .profile, unless you are
381.Em always
52309911 382on a 2621.
263cc8fc
CL
383.Bd -literal -offset indent
384export TERM; TERM=\`tset \- 2621\`
385.Ed
b5dc1377 386.Pp
52309911 387You have an h19 at home which you dial up on, but your office terminal
b5dc1377 388is hardwired and known in
263cc8fc
CL
389.Xr ttys 5 .
390.Bd -literal -offset indent
391export TERM; TERM=\`tset \- \-m dialup:h19\`
392.Ed
b5dc1377 393.Pp
52309911
KM
394You have a switch which connects everything to everything, making
395it nearly impossible to key on what port you are coming in on.
396You use a vt100 in your office at 9600 baud, and dial up to switch
397ports at 1200 baud from home on a 2621.
398Sometimes you use someone elses terminal at work,
399so you want it to ask you to make sure what terminal
400type you have at high speeds, but at 1200 baud you are
401always on a 2621.
402Note the placement of the question mark, and the quotes
403to protect the greater than and question mark from
404interpretation by the shell.
263cc8fc
CL
405.Bd -literal -offset indent
406export TERM; TERM=\`tset \- \-m 'switch>1200:?vt100'\e
407\-m 'switch<=1200:2621'
408.Ed
b5dc1377 409.Pp
52309911
KM
410All of the above entries will fall back on the terminal type
411specified in
b5dc1377 412.Xr ttys 5
52309911
KM
413if none of the conditions hold.
414The following entry is appropriate if
415you always dial up, always at the same baud rate,
416on many different kinds of terminals.
417Your most common terminal is an adm3a.
418It always asks you what kind of terminal you are on,
419defaulting to adm3a.
263cc8fc
CL
420.Bd -literal -offset indent
421export TERM; TERM=\`tset \- ?adm3a\`
422.Ed
b5dc1377 423.Pp
52309911 424If the file
b5dc1377 425.Xr ttys 5
52309911
KM
426is not properly installed and you want to
427key entirely on the baud rate, the following can be used:
263cc8fc
CL
428.Bd -literal -offset indent
429export TERM; TERM=\`tset \- \-m '>1200:vt100' 2621\`
430.Ed
b5dc1377 431.Pp
52309911 432Here is a fancy example to illustrate the power of
b5dc1377 433.Nm tset
52309911
KM
434and to hopelessly confuse anyone who has made it this far.
435You dial up at 1200 baud or less on a concept100,
436sometimes over switch ports and sometimes over regular dialups.
437You use various terminals at speeds higher than 1200 over switch ports,
438most often the terminal in your office, which is a vt100.
439However, sometimes you log in from the university you used to go to,
263cc8fc
CL
440over the
441.Tn ARPANET ;
442in this case you are on an
443.Tn ALTO
444emulating a dm2500.
52309911
KM
445You also often log in on various hardwired ports, such as the console,
446all of which are properly entered in
b5dc1377 447.Xr ttys 5 .
52309911
KM
448You want your erase character set to control H,
449your kill character set to control U,
450and don't want
b5dc1377
CL
451.Nm tset
452to print the
453.Dq Li Erase set to Backspace ,
454.Dq Li Kill set to Control U
455message.
263cc8fc
CL
456.Bd -literal -offset indent
457export TERM; TERM=\`tset \-e \-k^U \-Q \-\e
458\-m 'switch<=1200:concept100' \-m 'switch:?vt100'\e
459\-m dialup:concept100 \-m arpanet:dm2500\`
460.Ed
b5dc1377
CL
461.Sh ENVIRONMENT
462The
463.Nm tset
464command utilizes the
465.Ev TERM
466and
467.Ev TERMCAP
468environment variables.
469.Sh FILES
263cc8fc
CL
470.Bl -tag -width /usr/share/misc/termcap -compact
471.It Pa /etc/ttys
b5dc1377 472port name to terminal type mapping database
263cc8fc 473.It Pa /usr/share/misc/termcap
b5dc1377 474terminal capability database
263cc8fc 475.El
b5dc1377
CL
476.Sh SEE ALSO
477.Xr csh 1 ,
478.Xr sh 1 ,
479.Xr stty 1 ,
480.Xr ttys 5 ,
481.Xr termcap 5 ,
482.Xr environ 7
483.Sh HISTORY
263cc8fc
CL
484The
485.Nm tset
486command appeared in
487.Bx 3.0 .
b5dc1377
CL
488.Sh BUGS
489.Pp
52309911 490The
b5dc1377 491.Nm tset
52309911 492command is one of the first commands a user must master when getting
263cc8fc
CL
493started on a
494.Tn UNIX
495system.
52309911
KM
496Unfortunately, it is one of the most complex,
497largely because of the extra effort the user must go through
498to get the environment of the login shell set.
499Something needs to be done to make all this simpler,
500either the
b5dc1377 501.Xr login 1
52309911
KM
502program should do this stuff,
503or a default shell alias should be made,
504or a way to set the environment of the parent should exist.
b5dc1377 505.Pp
641c43e1
JB
506This program can't intuit personal choices for erase, interrupt
507and line kill characters, so it leaves these set to the local system
508standards.
263cc8fc
CL
509.\" .ig
510.\" .Sh NOTES
511.\" For compatibility with earlier versions of
512.\" .Nm tset
513.\" a number of flags are accepted whose use is discouraged:
514.\" .Bl -tag -width Fl
515.\" .It Fl d Ns Ar type
516.\" equivalent to
517.\" .Fl m
518.\" .Ar dialup:type
519.\" .It Fl p Ns Ar type
520.\" equivalent to
521.\" .Fl m
522.\" .Ar plugboard:type
523.\" .It Fl a Ns Ar type
524.\" equivalent to
525.\" .Fl m
526.\" .Ar arpanet:type
527.\" .It Fl E Ns Ar c
528.\" Sets the erase character to
529.\" .Ar c
530.\" only if the terminal can backspace.
531.\" .It Fl
532.\" prints the terminal type on the standard output
533.\" .It Fl r
534.\" prints the terminal type on the diagnostic output.
535.\" .El