]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.2 - patch 20210710
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2020,2021 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: tset.1,v 1.57 2021/07/10 22:50:45 tom Exp $
31 .TH @TSET@ 1 ""
32 .ie \n(.g .ds `` \(lq
33 .el       .ds `` ``
34 .ie \n(.g .ds '' \(rq
35 .el       .ds '' ''
36 .de bP
37 .ie n  .IP \(bu 4
38 .el    .IP \(bu 2
39 ..
40 .SH NAME
41 \fB@TSET@\fR, \fB@RESET@\fR \- terminal initialization
42 .SH SYNOPSIS
43 \fB@TSET@\fR [\fB\-IQVcqrsw\fR] [\fB\-\fR] [\fB\-e\fR \fIch\fR] [\fB\-i\fR \fIch\fR] [\fB\-k\fR \fIch\fR] [\fB\-m\fR \fImapping\fR] [\fIterminal\fR]
44 .br
45 \fB@RESET@\fR [\fB\-IQVcqrsw\fR] [\fB\-\fR] [\fB\-e\fR \fIch\fR] [\fB\-i\fR \fIch\fR] [\fB\-k\fR \fIch\fR] [\fB\-m\fR \fImapping\fR] [\fIterminal\fR]
46 .SH DESCRIPTION
47 .SS tset - initialization
48 This program initializes terminals.
49 .PP
50 First, \fB@TSET@\fR retrieves the current terminal mode settings
51 for your terminal.
52 It does this by successively testing
53 .bP
54 the standard error,
55 .bP
56 standard output,
57 .bP
58 standard input and
59 .bP
60 ultimately \*(``/dev/tty\*(''
61 .PP
62 to obtain terminal settings.
63 Having retrieved these settings, \fB@TSET@\fP remembers which
64 file descriptor to use when updating settings.
65 .PP
66 Next, \fB@TSET@\fP determines the type of terminal that you are using.
67 This determination is done as follows, using the first terminal type found.
68 .PP
69 1. The \fBterminal\fR argument specified on the command line.
70 .PP
71 2. The value of the \fBTERM\fR environmental variable.
72 .PP
73 3. (BSD systems only.) The terminal type associated with the standard
74 error output device in the \fI/etc/ttys\fR file.
75 (On System\-V-like UNIXes and systems using that convention,
76 \fIgetty\fR does this job by setting
77 \fBTERM\fR according to the type passed to it by \fI/etc/inittab\fR.)
78 .PP
79 4. The default terminal type, \*(``unknown\*(''.
80 .PP
81 If the terminal type was not specified on the command-line, the \fB\-m\fR
82 option mappings are then applied (see the section
83 .B TERMINAL TYPE MAPPING
84 for more information).
85 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
86 user is prompted for confirmation of the terminal type.
87 An empty
88 response confirms the type, or, another type can be entered to specify
89 a new type.
90 Once the terminal type has been determined,
91 the terminal description for the terminal is retrieved.
92 If no terminal description is found
93 for the type, the user is prompted for another terminal type.
94 .PP
95 Once the terminal description is retrieved,
96 .bP
97 if the \*(``\fB\-w\fP\*('' option is enabled, \fB@TSET@\fP may update
98 the terminal's window size.
99 .IP
100 If the window size cannot be obtained from the operating system,
101 but the terminal description (or environment, e.g., \fBLINES\fP
102 and \fBCOLUMNS\fP variables specify this),
103 use this to set the operating system's notion of the window size.
104 .bP
105 if the \*(``\fB\-c\fP\*('' option is enabled,
106 the backspace, interrupt and line kill characters
107 (among many other things) are set
108 .bP
109 unless the \*(``\fB\-I\fP\*('' option is enabled,
110 the terminal
111 and tab \fIinitialization\fP strings are sent to the standard error output,
112 and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
113 .bP
114 Finally, if the erase, interrupt and line kill characters have changed,
115 or are not set to their default values, their values are displayed to the
116 standard error output.
117 .SS reset - reinitialization
118 .PP
119 When invoked as \fB@RESET@\fR, \fB@TSET@\fR sets the terminal
120 modes to \*(``sane\*('' values:
121 .bP
122 sets cooked and echo modes,
123 .bP
124 turns off cbreak and raw modes,
125 .bP
126 turns on newline translation and
127 .bP
128 resets any unset special characters to their default values
129 .PP
130 before
131 doing the terminal initialization described above.
132 Also, rather than using the terminal \fIinitialization\fP strings,
133 it uses the terminal \fIreset\fP strings.
134 .PP
135 The \fB@RESET@\fP command is useful
136 after a program dies leaving a terminal in an abnormal state:
137 .bP
138 you may have to type
139 .sp
140     \fI<LF>\fP\fB@RESET@\fP\fI<LF>\fP
141 .sp
142 (the line-feed character is normally control-J) to get the terminal
143 to work, as carriage-return may no longer work in the abnormal state.
144 .bP
145 Also, the terminal will often not echo the command.
146 .SH OPTIONS
147 .PP
148 The options are as follows:
149 .TP 5
150 .B \-c
151 Set control characters and modes.
152 .TP 5
153 .B \-e
154 Set the erase character to \fIch\fR.
155 .TP
156 .B \-I
157 Do not send the terminal or tab initialization strings to the terminal.
158 .TP
159 .B \-i
160 Set the interrupt character to \fIch\fR.
161 .TP
162 .B \-k
163 Set the line kill character to \fIch\fR.
164 .TP
165 .B \-m
166 Specify a mapping from a port type to a terminal.
167 See the section
168 .B TERMINAL TYPE MAPPING
169 for more information.
170 .TP
171 .B \-Q
172 Do not display any values for the erase, interrupt and line kill characters.
173 Normally \fB@TSET@\fR displays the values for control characters which
174 differ from the system's default values.
175 .TP
176 .B \-q
177 The terminal type is displayed to the standard output, and the terminal is
178 not initialized in any way.
179 The option \*(``\-\*('' by itself is equivalent but archaic.
180 .TP
181 .B \-r
182 Print the terminal type to the standard error output.
183 .TP
184 .B \-s
185 Print the sequence of shell commands to initialize the environment variable
186 \fBTERM\fR to the standard output.
187 See the section
188 .B SETTING THE ENVIRONMENT
189 for details.
190 .TP
191 .B \-V
192 reports the version of ncurses which was used in this program, and exits.
193 .TP
194 .B \-w
195 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
196 Normally this has no effect,
197 unless \fBsetupterm\fP is not able to detect the window size.
198 .PP
199 The arguments for the \fB\-e\fR, \fB\-i\fR, and \fB\-k\fR
200 options may either be entered as actual characters
201 or by using the \*(``hat\*(''
202 notation, i.e., control-h may be specified as \*(``^H\*('' or \*(``^h\*(''.
203 .PP
204 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
205 .
206 .SH SETTING THE ENVIRONMENT
207 It is often desirable to enter the terminal type and information about
208 the terminal's capabilities into the shell's environment.
209 This is done using the \fB\-s\fR option.
210 .PP
211 When the \fB\-s\fR option is specified, the commands to enter the information
212 into the shell's environment are written to the standard output.
213 If
214 the \fBSHELL\fR environmental variable ends in \*(``csh\*('', the commands
215 are for \fBcsh\fR, otherwise, they are for \fBsh\fR.
216 Note, the \fBcsh\fR commands set and unset the shell variable
217 \fBnoglob\fR, leaving it unset.
218 The following line in the \fB.login\fR
219 or \fB.profile\fR files will initialize the environment correctly:
220 .sp
221     eval \`@TSET@ \-s options ... \`
222 .
223 .SH TERMINAL TYPE MAPPING
224 When the terminal is not hardwired into the system (or the current
225 system information is incorrect) the terminal type derived from the
226 \fI/etc/ttys\fR file or the \fBTERM\fR environmental variable is often
227 something generic like \fBnetwork\fR, \fBdialup\fR, or \fBunknown\fR.
228 When \fB@TSET@\fR is used in a startup script it is often desirable to
229 provide information about the type of terminal used on such ports.
230 .PP
231 The \fB\-m\fR options maps
232 from some set of conditions to a terminal type, that is, to
233 tell \fB@TSET@\fR
234 \*(``If I'm on this port at a particular speed,
235 guess that I'm on that kind of terminal\*(''.
236 .PP
237 The argument to the \fB\-m\fR option consists of an optional port type, an
238 optional operator, an optional baud rate specification, an optional
239 colon (\*(``:\*('') character and a terminal type.
240 The port type is a
241 string (delimited by either the operator or the colon character).
242 The operator may be any combination of
243 \*(``>\*('',
244 \*(``<\*('',
245 \*(``@\*('',
246 and \*(``!\*('';
247 \*(``>\*('' means greater than,
248 \*(``<\*('' means less than,
249 \*(``@\*('' means equal to and
250 \*(``!\*('' inverts the sense of the test.
251 The baud rate is specified as a number and is compared with the speed
252 of the standard error output (which should be the control terminal).
253 The terminal type is a string.
254 .PP
255 If the terminal type is not specified on the command line, the \fB\-m\fR
256 mappings are applied to the terminal type.
257 If the port type and baud
258 rate match the mapping, the terminal type specified in the mapping
259 replaces the current type.
260 If more than one mapping is specified, the
261 first applicable mapping is used.
262 .PP
263 For example, consider the following mapping: \fBdialup>9600:vt100\fR.
264 The port type is dialup , the operator is >, the baud rate
265 specification is 9600, and the terminal type is vt100.
266 The result of
267 this mapping is to specify that if the terminal type is \fBdialup\fR,
268 and the baud rate is greater than 9600 baud, a terminal type of
269 \fBvt100\fR will be used.
270 .PP
271 If no baud rate is specified, the terminal type will match any baud rate.
272 If no port type is specified, the terminal type will match any port type.
273 For example, \fB\-m dialup:vt100 \-m :?xterm\fR
274 will cause any dialup port, regardless of baud rate, to match the terminal
275 type vt100, and any non-dialup port type to match the terminal type ?xterm.
276 Note, because of the leading question mark, the user will be
277 queried on a default port as to whether they are actually using an xterm
278 terminal.
279 .PP
280 No whitespace characters are permitted in the \fB\-m\fR option argument.
281 Also, to avoid problems with meta-characters, it is suggested that the
282 entire \fB\-m\fR option argument be placed within single quote characters,
283 and that \fBcsh\fR users insert a backslash character (\*(``\e\*('') before
284 any exclamation marks (\*(``!\*('').
285 .SH HISTORY
286 .PP
287 A \fBreset\fP command appeared in 1BSD (March 1978), written by Kurt Shoens.
288 This program set the \fIerase\fP and \fIkill\fP characters
289 to \fB^H\fP (backspace) and \fB@\fP respectively.
290 Mark Horton improved that in 3BSD (October 1979), adding
291 \fIintr\fP, \fIquit\fP, \fIstart\fP/\fIstop\fP and \fIeof\fP characters
292 as well as changing the program to avoid modifying any user settings.
293 That version of \fBreset\fP did not use the termcap database.
294 .PP
295 A separate \fBtset\fP command was provided in 1BSD by Eric Allman,
296 using the termcap database.
297 Allman's comments in the source code indicate
298 that he began work in October 1977,
299 continuing development over the next few years.
300 .PP
301 According to comments in the source code,
302 the \fBtset\fP program was modified in September 1980,
303 to use logic copied from the 3BSD \*(``reset\*(''
304 when it was invoked as \fBreset\fP.
305 This version appeared in 4.1cBSD, late in 1982.
306 .PP
307 Other developers (e.g., Keith Bostic and Jim Bloom)
308 continued to modify \fBtset\fP until 4.4BSD was released in 1993.
309 .PP
310 The \fBncurses\fR implementation
311 was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
312 S. Raymond <esr@snark.thyrsus.com>.
313 .SH COMPATIBILITY
314 .PP
315 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
316 (POSIX.1-2008) nor
317 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
318 .PP
319 The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
320 incorporated the terminal-mode manipulation as well as termcap-based features
321 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
322 presumably with the intention of making \fBtset\fP obsolete.
323 However, each of those systems still provides \fBtset\fP.
324 In fact, the commonly-used \fBreset\fP utility
325 is always an alias for \fBtset\fP.
326 .PP
327 The \fB@TSET@\fR utility provides for backward-compatibility with BSD
328 environments (under most modern UNIXes, \fB/etc/inittab\fR and \fBgetty\fR(1)
329 can set \fBTERM\fR appropriately for each dial-up line; this obviates what was
330 \fB@TSET@\fR's most important use).
331 This implementation behaves like 4.4BSD
332 \fBtset\fP, with a few exceptions specified here.
333 .PP
334 A few options are different
335 because the \fBTERMCAP\fR variable
336 is no longer supported under terminfo-based \fBncurses\fR:
337 .bP
338 The \fB\-S\fR option of BSD \fBtset\fP no longer works;
339 it prints an error message to the standard error and dies.
340 .bP
341 The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.
342 .PP
343 There was an undocumented 4.4BSD feature
344 that invoking \fBtset\fP via a link named
345 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
346 set the terminal to use upper-case only.
347 This feature has been omitted.
348 .PP
349 The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
350 options were deleted from the \fB@TSET@\fR
351 utility in 4.4BSD.
352 None of them were documented in 4.3BSD and all are
353 of limited utility at best.
354 The \fB\-a\fR, \fB\-d\fR, and \fB\-p\fR options are similarly
355 not documented or useful, but were retained as they appear to be in
356 widespread use.
357 It is strongly recommended that any usage of these
358 three options be changed to use the \fB\-m\fR option instead.
359 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fR options
360 are therefore omitted from the usage summary above.
361 .PP
362 Very old systems, e.g., 3BSD, used a different terminal driver which
363 was replaced in 4BSD in the early 1980s.
364 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
365 \fB\-n\fP option to specify that the new terminal driver should be used.
366 This implementation does not provide that choice.
367 .PP
368 It is still permissible to specify the \fB\-e\fR, \fB\-i\fR,
369 and \fB\-k\fR options without arguments,
370 although it is strongly recommended that such usage be fixed to
371 explicitly specify the character.
372 .PP
373 As of 4.4BSD,
374 executing \fB@TSET@\fR as \fB@RESET@\fR no longer implies the \fB\-Q\fR option.
375 Also, the interaction between the \- option and the \fIterminal\fR
376 argument in some historic implementations of \fB@TSET@\fR has been removed.
377 .PP
378 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
379 However, a different window size-change feature was provided in 4.4BSD.
380 .bP
381 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
382 to set the window size if \fBtset\fP is not able to obtain the window
383 size from the operating system.
384 .bP
385 In ncurses, \fB@TSET@\fR obtains the window size using
386 \fBsetupterm\fP, which may be from
387 the operating system,
388 the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
389 the terminal description.
390 .PP
391 Obtaining the window size from the terminal description is common to
392 both implementations, but considered obsolescent.
393 Its only practical use is for hardware terminals.
394 Generally speaking, a window size would be unset only if there were
395 some problem obtaining the value from the operating system
396 (and \fBsetupterm\fP would still fail).
397 For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
398 may be useful for working around window-size problems.
399 Those have the drawback that if the window is resized,
400 those variables must be recomputed and reassigned.
401 To do this more easily, use the \fBresize\fP(1) program.
402 .SH ENVIRONMENT
403 The \fB@TSET@\fR command uses these environment variables:
404 .TP 5
405 SHELL
406 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP or
407 \fBcsh\fP syntax.
408 .TP 5
409 TERM
410 Denotes your terminal type.
411 Each terminal type is distinct, though many are similar.
412 .TP 5
413 TERMCAP
414 may denote the location of a termcap database.
415 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
416 \fB@TSET@\fP removes the variable from the environment before looking
417 for the terminal description.
418 .SH FILES
419 .TP 5
420 /etc/ttys
421 system port name to terminal type mapping database (BSD versions only).
422 .TP
423 @TERMINFO@
424 terminal capability database
425 .SH SEE ALSO
426 .hy 0
427 \fBcsh\fP(1),
428 \fBsh\fP(1),
429 \fBstty\fP(1),
430 \fBcurs_terminfo\fP(3X),
431 \fBtty\fP(4),
432 \fBterminfo\fP(5),
433 \fBttys\fP(5),
434 \fBenviron\fP(7)
435 .hy
436 .PP
437 This describes \fBncurses\fR
438 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).