]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.2 - patch 20200212
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright 2018,2020 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.55 2020/02/02 23:34:34 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 2BSD (April 1979), 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 .PP
294 Later in 4.1BSD (December 1980),
295 Mark Horton added a call to the \fBtset\fP program
296 using the \fB\-I\fP and \fB\-Q\fP options, i.e.,
297 using that to improve the terminal modes.
298 With those options,
299 that version of \fBreset\fP did not use the termcap database.
300 .PP
301 A separate \fBtset\fP command was provided in 2BSD by Eric Allman.
302 While the oldest published source (from 1979)
303 provides both \fBtset\fP and \fBreset\fP,
304 Allman's comments in the 2BSD source code indicate
305 that he began work in October 1977,
306 continuing development over the next few years.
307 .PP
308 In September 1980, Eric Allman modified \fBtset\fP,
309 adding the code from the existing \*(``reset\*(''
310 feature when \fBtset\fP was invoked as \fBreset\fP.
311 Rather than simply copying the existing program,
312 in this merged version, \fBtset\fP used the termcap database
313 to do additional (re)initialization of the terminal.
314 This version appeared in 4.1cBSD, late in 1982.
315 .PP
316 Other developers (e.g., Keith Bostic and Jim Bloom)
317 continued to modify \fBtset\fP until 4.4BSD was released in 1993.
318 .PP
319 The \fBncurses\fR implementation
320 was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
321 S. Raymond <esr@snark.thyrsus.com>.
322 .SH COMPATIBILITY
323 .PP
324 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
325 (POSIX.1-2008) nor
326 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
327 .PP
328 The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
329 incorporated the terminal-mode manipulation as well as termcap-based features
330 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
331 presumably with the intention of making \fBtset\fP obsolete.
332 However, each of those systems still provides \fBtset\fP.
333 In fact, the commonly-used \fBreset\fP utility
334 is always an alias for \fBtset\fP.
335 .PP
336 The \fB@TSET@\fR utility provides for backward-compatibility with BSD
337 environments (under most modern UNIXes, \fB/etc/inittab\fR and \fBgetty\fR(1)
338 can set \fBTERM\fR appropriately for each dial-up line; this obviates what was
339 \fB@TSET@\fR's most important use).
340 This implementation behaves like 4.4BSD
341 \fBtset\fP, with a few exceptions specified here.
342 .PP
343 A few options are different
344 because the \fBTERMCAP\fR variable
345 is no longer supported under terminfo-based \fBncurses\fR:
346 .bP
347 The \fB\-S\fR option of BSD \fBtset\fP no longer works;
348 it prints an error message to the standard error and dies.
349 .bP
350 The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.
351 .PP
352 There was an undocumented 4.4BSD feature
353 that invoking \fBtset\fP via a link named
354 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
355 set the terminal to use upper-case only.
356 This feature has been omitted.
357 .PP
358 The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
359 options were deleted from the \fB@TSET@\fR
360 utility in 4.4BSD.
361 None of them were documented in 4.3BSD and all are
362 of limited utility at best.
363 The \fB\-a\fR, \fB\-d\fR, and \fB\-p\fR options are similarly
364 not documented or useful, but were retained as they appear to be in
365 widespread use.
366 It is strongly recommended that any usage of these
367 three options be changed to use the \fB\-m\fR option instead.
368 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fR options
369 are therefore omitted from the usage summary above.
370 .PP
371 Very old systems, e.g., 3BSD, used a different terminal driver which
372 was replaced in 4BSD in the early 1980s.
373 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
374 \fB\-n\fP option to specify that the new terminal driver should be used.
375 This implementation does not provide that choice.
376 .PP
377 It is still permissible to specify the \fB\-e\fR, \fB\-i\fR,
378 and \fB\-k\fR options without arguments,
379 although it is strongly recommended that such usage be fixed to
380 explicitly specify the character.
381 .PP
382 As of 4.4BSD,
383 executing \fB@TSET@\fR as \fB@RESET@\fR no longer implies the \fB\-Q\fR option.
384 Also, the interaction between the \- option and the \fIterminal\fR
385 argument in some historic implementations of \fB@TSET@\fR has been removed.
386 .PP
387 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
388 However, a different window size-change feature was provided in 4.4BSD.
389 .bP
390 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
391 to set the window size if \fBtset\fP is not able to obtain the window
392 size from the operating system.
393 .bP
394 In ncurses, \fB@TSET@\fR obtains the window size using
395 \fBsetupterm\fP, which may be from
396 the operating system,
397 the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
398 the terminal description.
399 .PP
400 Obtaining the window size from the terminal description is common to
401 both implementations, but considered obsolescent.
402 Its only practical use is for hardware terminals.
403 Generally speaking, a window size would be unset only if there were
404 some problem obtaining the value from the operating system
405 (and \fBsetupterm\fP would still fail).
406 For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
407 may be useful for working around window-size problems.
408 Those have the drawback that if the window is resized,
409 those variables must be recomputed and reassigned.
410 To do this more easily, use the \fBresize\fP(1) program.
411 .SH ENVIRONMENT
412 The \fB@TSET@\fR command uses these environment variables:
413 .TP 5
414 SHELL
415 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP or
416 \fBcsh\fP syntax.
417 .TP 5
418 TERM
419 Denotes your terminal type.
420 Each terminal type is distinct, though many are similar.
421 .TP 5
422 TERMCAP
423 may denote the location of a termcap database.
424 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
425 \fB@TSET@\fP removes the variable from the environment before looking
426 for the terminal description.
427 .SH FILES
428 .TP 5
429 /etc/ttys
430 system port name to terminal type mapping database (BSD versions only).
431 .TP
432 @TERMINFO@
433 terminal capability database
434 .SH SEE ALSO
435 .hy 0
436 \fBcsh\fP(1),
437 \fBsh\fP(1),
438 \fBstty\fP(1),
439 \fBcurs_terminfo\fP(3X),
440 \fBtty\fP(4),
441 \fBterminfo\fP(5),
442 \fBttys\fP(5),
443 \fBenviron\fP(7)
444 .hy
445 .PP
446 This describes \fBncurses\fR
447 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).