broken up into multiple modules -- rewrite lots of it, reorganize the
[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.\"
263cc8fc 4.\" %sccs.include.redist.roff%
2088f2bf 5.\"
81ee81b5 6.\" @(#)tset.1 6.8 (Berkeley) %G%
2bcbe3d6 7.\"
b5dc1377
CL
8.Dd
9.Dt TSET 1
10.Os BSD 4
11.Sh NAME
12.Nm tset
81ee81b5 13.Nd terminal initialization
b5dc1377
CL
14.Sh SYNOPSIS
15.Nm tset
81ee81b5
KB
16.Op Fl IQs
17.Op Fl
18.Op Fl e Ar ch
19.Op Fl i Ar ch
20.Op Fl k Ar ch
21.Op Fl m Ar mapping
22.Op Ar terminal
23.br
b5dc1377 24.Nm reset
81ee81b5
KB
25.Op Fl IQs
26.Op Fl
27.Op Fl e Ar ch
28.Op Fl i Ar ch
29.Op Fl k Ar ch
30.Op Fl m Ar mapping
31.Op Ar terminal
b5dc1377
CL
32.Sh DESCRIPTION
33.Nm Tset
81ee81b5
KB
34initializes terminals.
35.Nm Tset
36first determines the type of terminal that you are using.
37This determination is done as follows, using the first terminal type found.
38.sp
39.Bl -bullet -compact -offset indent
40.It
41The
42.Ar terminal
43argument specified on the command line.
44.It
45The value of the
46.Ev TERM
47environmental variable.
48.It
49The terminal type associated with the standard error output device in the
50.Pa /etc/ttys
51file.
52.It
53The default terminal type, ``unknown''.
54.El
55.Pp
56If the terminal type was not specified on the command-line, the
57.Fl m
58option mappings are then applied (see below for more information).
59Then, if the terminal type begins with a question mark (``?''), the user is
60prompted for confirmation of the terminal type.
61An empty response confirms the type, or, another type can be entered to
62specify a new type.
63Once the terminal type has been determined, the termcap entry for the terminal
64is retrieved.
65If no termcap entry is found for the type, the user is prompted for another
66terminal type.
b5dc1377 67.Pp
81ee81b5
KB
68Once the termcap entry is retrieved, the window size, backspace, interrupt
69and line kill characters (among many other things) are set and the terminal
70and tab initialization strings are sent to the standard error output.
71Finally, if the erase, interrupt and line kill characters have changed,
72or are not set to their default values, their values are displayed to the
73standard error output.
74.Pp
75When invoked as
76.Nm reset ,
b5dc1377 77.Nm tset
81ee81b5
KB
78sets cooked and echo modes, turns off cbreak and raw modes, turns on
79newline translation and resets any unset special characters to their
80default values before doing the terminal initialization described above.
81This is useful after a program dies leaving a terminal in a abnormal state.
82Note, you may have to type
83.Dq Li <LF>reset<LF>
84(the line-feed character is normally control-J) to get the terminal
85to work, as carriage-return may no longer work in the abnormal state.
86Also, the terminal will often not echo the command.
b5dc1377 87.Pp
81ee81b5 88The options are as follows:
263cc8fc 89.Bl -tag -width flag
263cc8fc 90.It Fl
81ee81b5
KB
91The terminal type is displayed to the standard output, and the terminal is
92not initialized in any way.
93.It Fl e
94Set the erase character to
95.Ar ch .
96.It Fl I
97Do not send the terminal or tab initialization strings to the terminal.
98.It Fl i
99Set the interrupt character to
100.Ar ch .
101.It Fl k
102Set the line kill character to
103.Ar ch .
104.It Fl m
105Specify a mapping from a port type to a terminal.
106See below for more information.
263cc8fc 107.It Fl s
81ee81b5 108Print the sequence of shell commands to initialize the environment variables
b5dc1377
CL
109.Ev TERM
110and
111.Ev TERMCAP
81ee81b5 112to the standard output.
263cc8fc 113.It Fl Q
81ee81b5 114Don't display any values for the erase, interrupt and line kill characters.
263cc8fc 115.El
b5dc1377 116.Pp
81ee81b5
KB
117The arguments for the
118.Fl e ,
119.Fl i
120and
121.Fl k
122options may either be entered as actual characters or by using the
123.Dq hat
124notation, i.e. control-h may be specified as
125.Dq Li ^H
126or
127.Dq Li ^h .
128.Sh SETTING THE ENVIRONMENT
129It is often desirable to set the terminal type and information about the
130terminal's capabilities in the shell's environment.
131This is done with the
132.Fl s
133option; when this option is specified, the commands to enter the information
134into the shell's environment are output to the standard output.
135If the
136.Ev SHELL
137environmental variable ends in ``csh'', the output commands are for the
138.Xr csh 1 ,
139otherwise, they are for
140.Xr sh 1 .
141Note, the output commands for the
142.Nm csh
143set and unset the shell variable
144.Dq noglob .
145The following line in the
146.Pa .login
147or
148.Pa .profile
149files will initialize the environment correctly:
150.Bd -literal -offset indent
151eval \`tset -s options ... \`
152.Ed
153.Sh TERMINAL TYPE MAPPING
154When the terminal is not hardwired into the system (or the current system
155information is incorrect) the terminal type derived from the
156.Pa /etc/ttys
157file or the
158.Ev TERM
159environmental variable is often something generic like
160.Dq network ,
161.Dq dialup ,
162or
163.Dq unknown .
164When
165.Nm tset
166is used in a startup script
263cc8fc 167.Pf ( Pa .profile
b5dc1377 168for
81ee81b5 169.Xr sh 1
52309911 170users or
263cc8fc 171.Pa .login
52309911 172for
263cc8fc 173.Xr csh 1
81ee81b5
KB
174users) it is often desirable to provide information about the type of
175terminal used on such ports.
176The purpose of the
b5dc1377 177.Fl m
81ee81b5
KB
178option is to
179.Dq map
180from some set of conditions to a terminal type, that is, to
181tell
b5dc1377 182.Nm tset
81ee81b5
KB
183``If I'm on this port at a particular speed, guess that I'm on that
184kind of terminal''.
b5dc1377 185.Pp
81ee81b5 186The argument to the
b5dc1377 187.Fl m
81ee81b5
KB
188option consists of an optional port type, an optional operator, an optional
189baud rate specification, an optional colon (``:'') character and a terminal
190type.
191The port type is a string (delimited by either the operator or the colon
192character).
193The operator may be any combination of:
194.Dq Li \&> ,
195.Dq Li \&< ,
196.Dq Li \&@ ,
b5dc1377 197and
81ee81b5
KB
198.Dq Li \&! ;
199.Dq Li \&>
200means greater than,
201.Dq Li \&<
202means less than,
203.Dq Li \&@
204means equal to
52309911 205and
81ee81b5
KB
206.Dq Li \&!
207inverts the sense of the test.
208The baud rate is specified as a number and is compared with the speed
209of the standard error output (which should be the control terminal).
210The terminal type is a string.
b5dc1377 211.Pp
81ee81b5
KB
212If the terminal type is not specified on the command line, the
213.Fl m
214mappings are applied to the terminal type.
215If the port type and baud rate match the mapping, the terminal type specified
216in the mapping replaces the current type.
217If more than one mapping is specified, the first applicable mapping is used.
b5dc1377 218.Pp
81ee81b5
KB
219For example, consider the following:
220.Dq Li dialup>9600:vt100 .
221The port type is
222.Dq Li dialup ,
223the operator is
224.Dq Li > ,
225the baud rate specification is
226.Dq Li 9600 ,
227and the terminal type is
228.Dq Li vt100 .
229The result of this mapping is to specify that if the terminal type is
230.Dq Li dialup ,
231and the baud rate is greater than 9600 baud, a terminal type of
232.Dq Li vt100
233will be used.
b5dc1377 234.Pp
81ee81b5
KB
235If no port type is specified, the terminal type will match any port type,
236for example,
237.Dq Li -m dialup:vt100 -m :?xterm
238will cause any dialup port, regardless of baud rate, to match the terminal
239type
240.Dq Li vt100 ,
241and any non-dialup port type to match the terminal type
242.Dq Li ?xterm .
243Note, because of the leading question mark, the user will be
244queried on a default port as to whether they are actually using an
245.Ar xterm
246terminal.
b5dc1377 247.Pp
81ee81b5
KB
248No whitespace characters are permitted in the
249.Fl m
250option argument.
251A missing port type matches all port types.
252To avoid problems with metacharacters, it is best to place the entire
253.Fl m
254option within single quote characters.
255.Nm Csh
256users normally must also place a backslash character (``\e'') before any
257exclamation marks (``!'').
b5dc1377
CL
258.Sh ENVIRONMENT
259The
260.Nm tset
261command utilizes the
81ee81b5 262.Ev SHELL ,
b5dc1377
CL
263.Ev TERM
264and
265.Ev TERMCAP
266environment variables.
267.Sh FILES
263cc8fc
CL
268.Bl -tag -width /usr/share/misc/termcap -compact
269.It Pa /etc/ttys
81ee81b5 270system port name to terminal type mapping database
263cc8fc 271.It Pa /usr/share/misc/termcap
b5dc1377 272terminal capability database
263cc8fc 273.El
b5dc1377
CL
274.Sh SEE ALSO
275.Xr csh 1 ,
276.Xr sh 1 ,
277.Xr stty 1 ,
81ee81b5 278.Xr tty 4 ,
b5dc1377 279.Xr termcap 5 ,
81ee81b5 280.Xr ttys 5 ,
b5dc1377
CL
281.Xr environ 7
282.Sh HISTORY
263cc8fc
CL
283The
284.Nm tset
285command appeared in
286.Bx 3.0 .
81ee81b5
KB
287.Sh COMPATIBILITY
288The historic
289.Fl A ,
290.Fl a ,
291.Fl d ,
292.Fl E ,
293.Fl h ,
294.Fl p ,
295.Fl r ,
296.Fl S ,
297.Fl u
298and
299.Fl v
300options have been deleted from the
301.Nm tset
302utility.
303None of these flags were documented in 4.3BSD and all are of limited
304utility at best.
305Executing
306.Nm tset
307as
308.Nm reset
309no longer implies the
310.Fl Q
311option.
52309911 312The
81ee81b5
KB
313.Fl n
314option remains, but has no effect.
315.Pp
316It is still permissible to specify the
317.Fl e ,
318.Fl i
319and
320.Fl k
321options without arguments, although it is strongly recommended that such
322usage be fixed to conform to
323.Xr getopt 3 .
324Also, some historic implementations of
b5dc1377 325.Nm tset
81ee81b5
KB
326had an interaction between the
327.Fl
328option and the
329.Ar terminal
330argument.
331This is no longer true.
b5dc1377 332.Pp
81ee81b5
KB
333Finally, the
334.Nm tset
335implementation has been completely redone as part of the addition to the
336system of a
337.St -p1003.1-88
338compliant terminal interface, and will no longer compile on systems with
339older terminal interfaces.