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