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