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