xref: /original-bsd/usr.bin/tset/tset.1 (revision a91856c6)
1.\" Copyright (c) 1985, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)tset.1	6.6 (Berkeley) 03/14/91
7.\"
8.Vx
9.Vx
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
44sets up your terminal when you first log in to a UNIX system.
45It does terminal dependent processing such as setting
46erase and kill characters, setting or resetting delays,
47sending any sequences needed to properly initialized the terminal,
48and the like.
49It first determines the
50.Ar type
51of terminal involved,
52and then does necessary initializations and mode settings.
53The type of terminal attached to each
54UNIX
55port is specified in the
56.Xr ttys  5
57database.
58Type names for terminals may be found in the
59.Xr termcap  5
60database.
61If a port is not wired permanently to a specific terminal (not hardwired)
62it will be given an appropriate generic identifier such as
63.Ar dialup  .
64.Pp
65In the case where no arguments are specified,
66.Nm tset
67simply reads the terminal type out of the environment variable
68.Ev TERM
69and re-initializes the terminal.  The rest of this manual concerns
70itself with mode and environment initialization,
71typically done once at login, and options
72used at initialization time to determine the terminal type and set up
73terminal modes.
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
152When used in a startup script
153.Pf \&( Pa \&.profile
154for
155.Xr sh  1
156users or
157.Pa \&.login
158for
159.Xr csh  1
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
163.Xr ttys 5
164as
165.Li dialup
166or
167.Li plugboard
168or
169.Li arpanet ,
170etc.
171To specify
172what terminal type you usually use on these ports, the
173.Fl m
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
179.Nm tset
180``If I'm on this kind of port, guess that I'm on that kind of terminal''.)
181If more than one mapping is specified, the first applicable mapping prevails.
182A missing port type identifier matches all identifiers.
183Any of the alternate generic names given in
184.Xr termcap 5
185may be used for the identifier.
186.Pp
187A
188.Ar baudrate
189is specified as with
190.Xr stty  1  ,
191and is compared with the
192speed of the diagnostic output (which should be the control terminal).
193The baud rate
194.Ar test
195may be any combination of:
196.Ic \&> ,
197.Ic \&@ ,
198.Ic \&< ,
199and
200.Ic \&! ;
201.Ic \&@
202means ``at''
203and
204.Ic \&!
205inverts the sense of the test.  To avoid problems with metacharacters, it
206is best to place the entire argument to
207.Fl m
208within ``\''' characters; users of
209.Xr csh  1
210must also put a ``\e'' before any ``!'' used here.
211.Pp
212.Df I
213tset \-m \'dialup>300:adm3a\' -m dialup:dw2 -m \'plugboard:?adm3a\'
214.De
215.Pp
216causes the terminal type to be set to an
217.Ar adm3a
218if the port in use is a dialup at a speed greater than 300 baud;
219to a
220.Ar dw2
221if the port is (otherwise) a dialup (i.e. at 300 baud or less).
222.Ar NOTE :
223the examples given here appear to take up more than
224one line, for text processing reasons.  When you type in real
225.Nm tset
226commands, you must enter them entirely on one line.
227If the
228.Ar type
229finally determined by
230.Nm tset
231begins with a question mark,
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.
235Thus, in the above case, the user will be queried on a plugboard port
236as to whether they are actually using an
237.Ar adm3a  .
238.Pp
239If no mapping applies and a final
240.Ar type
241option, not preceded by a
242.Fl m  ,
243is given on the command line
244then that type is used;
245otherwise the type found in the
246.Xr ttys 5
247database will be taken to be the terminal type.
248This should always be the case for hardwired ports.
249.Pp
250It is usually desirable to return the terminal type, as finally determined by
251.Nm tset  ,
252and information about the terminal's capabilities
253to a shell's environment.  This can be done using the
254.Fl
255option; using the Bourne shell,
256.Xr sh  1  :
257.Pp
258.Df I
259.Li export TERM; TERM=\&\`tset \-
260.Ar options ...
261.Li \&\`
262.De
263.Pp
264or using the C shell,
265.Xr csh  1  :
266.Pp
267.Df I
268.Li setenv TERM \`tset \-
269.Ar options . . .
270.Li \&\`
271.De
272.Pp
273With
274.Xr csh 1
275it is preferable to use the following command in your .login file to
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
288It is also convenient to make an alias in your .cshrc:
289.Pp
290.Dl alias tset \'eval \`tset \-s \e!*\`\'
291.Pp
292This allows the command:
293.Pp
294.Dl tset 2621
295.Pp
296to be invoked at any time to set the terminal and environment.
297.Sy Note to Bourne Shell users:
298It is
299.Em not
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.)
304.Pp
305These commands cause
306.Nm tset
307to place the name of your terminal in the variable
308.Ev TERM
309in the environment; see
310.Xr environ  7  .
311.Pp
312Once the terminal type is known,
313.Nm tset
314engages in terminal driver mode setting.
315This normally involves sending an initialization sequence to the
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.
321.Pp
322On terminals that can backspace but not overstrike
323(such as a
324.Em CRT ) ,
325and when the erase character is the default erase character
326(`#' on standard systems),
327the erase character is changed to
328.Li BACKSPACE
329(Control-H).
330.Pp
331If
332.Nm tset
333is invoked as
334.Nm reset  ,
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.
338Any special character that is found to be
339.Li NULL
340or ``\-1'' is reset to its default value.  All arguments to
341.Nm tset
342may be used with reset.
343.Pp
344This is most useful after a program dies leaving a terminal in a funny
345state. You may have to type
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.
356If you use
357.Xr csh  ,
358use one of the variations described above.
359Note that a typical use of
360.Nm tset
361in a
362.Pa .profile or
363.Pa .login
364will also use the
365.Fl e
366and
367.Fl k
368options, and often the
369.Fl n
370or
371.Fl Q
372options as well.
373These options have not been included here to keep the examples small.
374.Sy NOTE :
375some of the examples given here appear to take up more than
376one line, for text processing reasons.  When you type in real
377.Nm tset
378commands, you must enter them entirely on one line.
379.Pp
380At the moment, you are on a
381.Li 2621 .
382This is suitable for typing by hand but
383not for a
384.Pa .profile, unless you are
385.Em always
386on a 2621.
387.Pp
388.Dl export TERM; TERM=\`tset \- 2621\`
389.Pp
390You have an h19 at home which you dial up on, but your office terminal
391is hardwired and known in
392Xr ttys 5 .
393.Pp
394.Dl export
395TERM; TERM=\`tset \- \-m dialup:h19\`
396.Pp
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.
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
415All of the above entries will fall back on the terminal type
416specified in
417.Xr ttys 5
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.
425.Pp
426.Dl export TERM; TERM=\`tset \- \?adm3a\`
427.Pp
428If the file
429.Xr ttys 5
430is not properly installed and you want to
431key entirely on the baud rate, the following can be used:
432.Pp
433.Dl export TERM; TERM=\`tset \- \-m '>1200:vt100' 2621\`
434.Pp
435Here is a fancy example to illustrate the power of
436.Nm tset
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
446.Xr ttys 5 .
447You want your erase character set to control H,
448your kill character set to control U,
449and don't want
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
492The
493.Nm tset
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
501.Xr login  1
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.
505.Pp
506This program can't intuit personal choices for erase, interrupt
507and line kill characters, so it leaves these set to the local system
508standards.
509.ig
510.Sh NOTES
511For compatibility with earlier versions of
512.Nm tset
513a number of flags are accepted whose use is discouraged:
514.Tw Fl
515.Tp Cx Fl d
516.Ar type
517.Cx
518equivalent to
519.Fl m
520.Ar dialup:type
521.Tp Cx Fl p
522.Ar type
523.Cx
524equivalent to
525.Fl m
526.Ar plugboard:type
527.Tp Cx Fl a
528.Ar type
529.Cx
530equivalent to
531.Fl m
532.Ar arpanet:type
533.Cx
534.Tp Cx Fl E
535.Ar c
536.Cx
537Sets the erase character to
538.Ar c
539only if the terminal can backspace.
540.Tp Fl
541prints the terminal type on the standard output
542.Tp Fl r
543prints the terminal type on the diagnostic output.
544.Tp
545..
546