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