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