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