install with -s
[unix-history] / usr / src / usr.bin / tset / tset.1
... / ...
CommitLineData
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.\"
5.\" @(#)tset.1 6.1 (Berkeley) %G%
6.\"
7.TH TSET 1 ""
8.UC 4
9.SH NAME
10tset \- terminal dependent initialization
11.SH SYNOPSIS
12.B tset
13[ options ] [
14.B \-m
15[ident][test baudrate]:type ] \&... [ type ]
16.sp 1
17.B reset
18\&...
19.SH DESCRIPTION
20.I Tset
21sets up your terminal when you first log in to a UNIX system.
22It does terminal dependent processing such as setting
23erase and kill characters, setting or resetting delays,
24sending any sequences needed to properly initialized the terminal,
25and the like.
26It first determines the
27.I type
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
31.IR /etc/ttys (5)
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,
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
44itself with mode and environment initialization,
45typically done once at login, and options
46used at initialization time to determine the terminal type and set up
47terminal modes.
48.PP
49When used in a startup script (\fI\&.profile\fR for
50.IR sh (1)
51users or
52.I \&.login
53for
54.IR csh (1)
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
58.I /etc/ttys
59as
60.I dialup
61or
62.I plugboard
63or
64.I arpanet,
65etc.
66To specify
67what terminal type you usually use on these ports, the
68.B \-m
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''.)
76If more than one mapping is specified, the first applicable mapping prevails.
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.
81.PP
82A
83.I baudrate
84is specified as with
85.IR stty (1),
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 < ,
94and
95.BR ! ;
96.B @
97means ``at''
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
107.KS
108Thus
109.IP
110tset \-m \'dialup>300:adm3a\' -m dialup:dw2 -m \'plugboard:?adm3a\'
111.KE
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).
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.)
123If the
124.I type
125finally determined by
126.I tset
127begins with a question mark,
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.
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
136.I type
137option, not preceded by a
138.BR \-m ,
139is given on the command line
140then that type is used;
141otherwise the type found in the
142.I /etc/ttys
143database will be taken to be the terminal type.
144This should always be the case for hardwired ports.
145.PP
146It is usually desirable to return the terminal type, as finally determined by
147.IR tset ,
148and information about the terminal's capabilities
149to a shell's environment. This can be done using the
150.B \-
151option; using the Bourne shell,
152.IR sh (1):
153.IP
154export TERM; TERM=\`tset \- \fIoptions...\fR\`
155.LP
156or using the C shell,
157.IR csh (1):
158.IP
159setenv TERM \`tset - \fIoptions...\fR\`
160.PP
161With
162.I csh
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!*\`\'
171.PP
172This allows the command:
173.IP
174tset 2621
175.PP
176to be invoked at any time to set the terminal and environment.
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.)
184.PP
185These commands cause
186.I tset
187to place the name of your terminal in the variable
188TERM in the environment; see
189.IR environ (7).
190.PP
191Once the terminal type is known,
192.I tset
193engages in terminal driver mode setting.
194This normally involves sending an initialization sequence to the
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.
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),
205the erase character is changed to \s-2BACKSPACE\s0 (Control-H).
206.PP
207The options are:
208.TP
209.B \-e\fIc
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.
214The character
215.I c
216can either be typed directly, or entered using the hat
217notation used here.
218.TP
219.B \-k\fIc
220is similar to
221.B \-e
222but for the line kill character rather than the erase character;
223.I c
224defaults to ^X (for purely historical reasons).
225The kill characters is left alone if
226.B \-k
227is not specified.
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
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
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.
249.TP
250.B \-I
251suppresses transmitting terminal initialization strings.
252.TP
253.B \-Q
254suppresses printing the
255``Erase set to'' and ``Kill set to'' messages.
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
302is hardwired and known in /etc/ttys.
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
322.I /etc/ttys
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
334.I /etc/ttys
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
351.IR /etc/ttys .
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\`
359.SH FILES
360.DT
361/etc/ttys port name to terminal type mapping database
362.br
363/etc/termcap terminal capability database
364.SH SEE\ ALSO
365csh(1), sh(1), stty(1), ttys(5), termcap(5), environ(7)
366.SH AUTHORS
367Eric Allman
368.br
369David Wasley
370.br
371Mark Horton
372.SH BUGS
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
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.
418..