1 .\" $NetBSD: tset.1,v 1.15 2004/07/23 13:35:02 wiz Exp $
3 .\" Copyright (c) 1985, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)tset.1 8.1 (Berkeley) 6/9/93
38 .Nd terminal initialization
59 initializes terminals.
61 first determines the type of terminal that you are using.
62 This determination is done as follows, using the first terminal type found.
64 .Bl -bullet -compact -offset indent
68 argument specified on the command line.
72 environmental variable.
74 The terminal type associated with the standard error output device in the
78 The default terminal type,
82 If the terminal type was not specified on the command-line, the
84 option mappings are then applied (see below for more information).
85 Then, if the terminal type begins with a question mark (``?''), the user is
86 prompted for confirmation of the terminal type.
87 An empty response confirms the type, or, another type can be entered to
89 Once the terminal type has been determined, the termcap entry for the terminal
91 If no termcap entry is found for the type, the user is prompted for another
94 Once the termcap entry is retrieved, the window size, backspace, interrupt
95 and line kill characters (among many other things) are set and the terminal
96 and tab initialization strings are sent to the standard error output.
97 Finally, if the erase, interrupt and line kill characters have changed,
98 or are not set to their default values, their values are displayed to the
99 standard error output.
104 sets cooked and echo modes, turns off cbreak and raw modes, turns on
105 newline translation and resets any unset special characters to their
106 default values before doing the terminal initialization described above.
107 This is useful after a program dies leaving a terminal in a abnormal state.
108 Note, you may have to type
109 .Dq Li \*[Lt]LF\*[Gt]reset\*[Lt]LF\*[Gt]
110 (the line-feed character is normally control-J) to get the terminal
111 to work, as carriage-return may no longer work in the abnormal state.
112 Also, the terminal will often not echo the command.
114 The options are as follows:
117 The terminal type is displayed to the standard output, and the terminal is
118 not initialized in any way.
120 Emit the extended termcap entry.
121 By default the termcap entry is
122 truncated to 1024 bytes, this flag specifies the untruncated termcap
123 entry is to be output.
124 Using this flag may cause problems with some
127 Set the erase character to
130 Do not send the terminal or tab initialization strings to the terminal.
132 Set the interrupt character to
135 Set the line kill character to
138 Specify a mapping from a port type to a terminal.
139 See below for more information.
141 Don't display any values for the erase, interrupt and line kill characters.
143 Print the terminal type to the standard error output.
145 Print the terminal type and the termcap entry to the standard output.
146 See the section below on setting the environment for details.
148 Print the sequence of shell commands to initialize the environment variables
152 to the standard output.
153 See the section below on setting the environment for details.
156 The arguments for the
161 options may either be entered as actual characters or by using the
163 notation, i.e. control-h may be specified as
167 .Sh SETTING THE ENVIRONMENT
168 It is often desirable to enter the terminal type and information about
169 the terminal's capabilities into the shell's environment.
170 This is done using the
178 option is specified, the terminal type and the termcap entry are written
179 to the standard output, separated by a space and without a terminating
181 This can be assigned to an array by
185 users and then used like any other shell array.
189 option is specified, the commands to enter the information into the
190 shell's environment are written to the standard output.
193 environmental variable ends in
195 the commands are for the
197 otherwise, they are for
208 The following line in the
212 files will initialize the environment correctly:
213 .Bd -literal -offset indent
214 eval \`tset -s options ... \`
217 To demonstrate a simple use of the
219 option, the following lines in the
221 file have an equivalent effect:
222 .Bd -literal -offset indent
224 set term=(`tset -S options ...`)
226 setenv TERMCAP "$term[2]"
230 .Sh TERMINAL TYPE MAPPING
231 When the terminal is not hardwired into the system (or the current system
232 information is incorrect) the terminal type derived from the
236 environmental variable is often something generic like
243 is used in a startup script
251 users) it is often desirable to provide information about the type of
252 terminal used on such ports.
257 from some set of conditions to a terminal type, that is, to
260 ``If I'm on this port at a particular speed, guess that I'm on that
265 option consists of an optional port type, an optional operator, an optional
266 baud rate specification, an optional colon (``:'') character and a terminal
268 The port type is a string (delimited by either the operator or the colon
270 The operator may be any combination of:
284 inverts the sense of the test.
285 The baud rate is specified as a number and is compared with the speed
286 of the standard error output (which should be the control terminal).
287 The terminal type is a string.
289 If the terminal type is not specified on the command line, the
291 mappings are applied to the terminal type.
292 If the port type and baud rate match the mapping, the terminal type specified
293 in the mapping replaces the current type.
294 If more than one mapping is specified, the first applicable mapping is used.
296 For example, consider the following mapping:
297 .Dq Li dialup\*[Gt]9600:vt100 .
302 the baud rate specification is
304 and the terminal type is
306 The result of this mapping is to specify that if the terminal type is
308 and the baud rate is greater than 9600 baud, a terminal type of
312 If no port type is specified, the terminal type will match any port type,
314 .Dq Li -m dialup:vt100 -m :?xterm
315 will cause any dialup port, regardless of baud rate, to match the terminal
318 and any non-dialup port type to match the terminal type
320 Note, because of the leading question mark, the user will be
321 queried on a default port as to whether they are actually using an
325 No whitespace characters are permitted in the
328 Also, to avoid problems with metacharacters, it is suggested that the entire
330 option argument be placed within single quote characters, and that
332 users insert a backslash character (``\e'') before any exclamation
341 environment variables.
343 .Bl -tag -width /usr/share/misc/termcap -compact
345 system port name to terminal type mapping database
346 .It Pa /usr/share/misc/termcap
347 terminal capability database
370 options have been deleted from the
373 None of them were documented in
375 and all are of limited utility at
382 options are similarly not documented or useful, but were retained as they
383 appear to be in widespread use.
384 It is strongly recommended that any usage of these three options be
390 option remains, but has no effect.
391 It is still permissible to specify the
396 options without arguments, although it is strongly recommended that such
397 usage be fixed to explicitly specify the character.
403 no longer implies the
406 Also, the interaction between the
410 argument in some historic implementations of
416 implementation has been completely redone (as part of the addition to the
419 compliant terminal interface) and will no longer compile on systems with
420 older terminal interfaces.