]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.4 - patch 20230701
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 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.66 2023/07/01 15:21:06 tom Exp $
31 .TH @TSET@ 1 2023-07-01 "ncurses 6.4" "User commands"
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@\fP, \fB@RESET@\fP \- terminal initialization
42 .SH SYNOPSIS
43 \fB@TSET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal\fP]
44 .br
45 \fB@RESET@\fP [\fB\-IQVcqrsw\fP] [\fB\-\fP] [\fB\-e\fP \fIch\fP] [\fB\-i\fP \fIch\fP] [\fB\-k\fP \fIch\fP] [\fB\-m\fP \fImapping\fP] [\fIterminal\fP]
46 .SH DESCRIPTION
47 .SS tset - initialization
48 This program initializes terminals.
49 .PP
50 First, \fB@TSET@\fP 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\fP argument specified on the command line.
70 .PP
71 2. The value of the \fBTERM\fP 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\fP file.
75 (On System\-V-like UNIXes and systems using that convention,
76 \fBgetty\fP(1) does this job by setting
77 \fBTERM\fP according to the type passed to it by \fI/etc/inittab\fP.)
78 .PP
79 4. The default terminal type, \*(``unknown\*('',
80 is not suitable for curses applications.
81 .PP
82 If the terminal type was not specified on the command-line, the \fB\-m\fP
83 option mappings are then applied (see the section
84 .B TERMINAL TYPE MAPPING
85 for more information).
86 Then, if the terminal type begins with a question mark (\*(``?\*(''), the
87 user is prompted for confirmation of the terminal type.
88 An empty
89 response confirms the type, or, another type can be entered to specify
90 a new type.
91 Once the terminal type has been determined,
92 the terminal description for the terminal is retrieved.
93 If no terminal description is found
94 for the type, the user is prompted for another terminal type.
95 .PP
96 Once the terminal description is retrieved,
97 .bP
98 if the \*(``\fB\-w\fP\*('' option is enabled, \fB@TSET@\fP may update
99 the terminal's window size.
100 .IP
101 If the window size cannot be obtained from the operating system,
102 but the terminal description (or environment, e.g., \fBLINES\fP
103 and \fBCOLUMNS\fP variables specify this),
104 use this to set the operating system's notion of the window size.
105 .bP
106 if the \*(``\fB\-c\fP\*('' option is enabled,
107 the backspace, interrupt and line kill characters
108 (among many other things) are set
109 .bP
110 unless the \*(``\fB\-I\fP\*('' option is enabled,
111 the terminal
112 and tab \fIinitialization\fP strings are sent to the standard error output,
113 and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
114 .bP
115 Finally, if the erase, interrupt and line kill characters have changed,
116 or are not set to their default values, their values are displayed to the
117 standard error output.
118 .SS reset - reinitialization
119 When invoked as \fB@RESET@\fP, \fB@TSET@\fP 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>\fB@RESET@\fI<LF>\fR
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 The options are as follows:
148 .TP 5
149 .B \-c
150 Set control characters and modes.
151 .TP 5
152 .BI \-e\  ch
153 Set the erase character to \fIch\fP.
154 .TP
155 .B \-I
156 Do not send the terminal or tab initialization strings to the terminal.
157 .TP
158 .BI \-i\  ch
159 Set the interrupt character to \fIch\fP.
160 .TP
161 .BI \-k\  ch
162 Set the line kill character to \fIch\fP.
163 .TP
164 .BI \-m\  mapping
165 Specify a mapping from a port type to a terminal.
166 See the section
167 .B TERMINAL TYPE MAPPING
168 for more information.
169 .TP
170 .B \-Q
171 Do not display any values for the erase, interrupt and line kill characters.
172 Normally \fB@TSET@\fP displays the values for control characters which
173 differ from the system's default values.
174 .TP
175 .B \-q
176 The terminal type is displayed to the standard output, and the terminal is
177 not initialized in any way.
178 The option \*(``\-\*('' by itself is equivalent but archaic.
179 .TP
180 .B \-r
181 Print the terminal type to the standard error output.
182 .TP
183 .B \-s
184 Print the sequence of shell commands to initialize the environment variable
185 \fBTERM\fP to the standard output.
186 See the section
187 .B SETTING THE ENVIRONMENT
188 for details.
189 .TP
190 .B \-V
191 reports the version of ncurses which was used in this program, and exits.
192 .TP
193 .B \-w
194 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
195 Normally this has no effect,
196 unless \fBsetupterm\fP is not able to detect the window size.
197 .PP
198 The arguments for the \fB\-e\fP, \fB\-i\fP, and \fB\-k\fP
199 options may either be entered as actual characters
200 or by using the \*(``hat\*(''
201 notation, i.e., control-h may be specified as \*(``^H\*('' or \*(``^h\*(''.
202 .PP
203 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
204 .
205 .SH SETTING THE ENVIRONMENT
206 It is often desirable to enter the terminal type and information about
207 the terminal's capabilities into the shell's environment.
208 This is done using the \fB\-s\fP option.
209 .PP
210 When the \fB\-s\fP option is specified, the commands to enter the information
211 into the shell's environment are written to the standard output.
212 If
213 the \fBSHELL\fP environmental variable ends in \*(``csh\*('', the commands
214 are for \fBcsh\fP, otherwise, they are for \fBsh\fP(1).
215 Note, the \fBcsh\fP commands set and unset the shell variable
216 \fBnoglob\fP, leaving it unset.
217 The following line in the \fB.login\fP
218 or \fB.profile\fP files will initialize the environment correctly:
219 .sp
220     eval \`@TSET@ \-s options ... \`
221 .
222 .SH TERMINAL TYPE MAPPING
223 When the terminal is not hardwired into the system (or the current
224 system information is incorrect) the terminal type derived from the
225 \fI/etc/ttys\fP file or the \fBTERM\fP environmental variable is often
226 something generic like \fBnetwork\fP, \fBdialup\fP, or \fBunknown\fP.
227 When \fB@TSET@\fP is used in a startup script it is often desirable to
228 provide information about the type of terminal used on such ports.
229 .PP
230 The \fB\-m\fP options maps
231 from some set of conditions to a terminal type, that is, to
232 tell \fB@TSET@\fP
233 \*(``If I'm on this port at a particular speed,
234 guess that I'm on that kind of terminal\*(''.
235 .PP
236 The argument to the \fB\-m\fP option consists of an optional port type, an
237 optional operator, an optional baud rate specification, an optional
238 colon (\*(``:\*('') character and a terminal type.
239 The port type is a
240 string (delimited by either the operator or the colon character).
241 The operator may be any combination of
242 \*(``>\*('',
243 \*(``<\*('',
244 \*(``@\*('',
245 and \*(``!\*('';
246 \*(``>\*('' means greater than,
247 \*(``<\*('' means less than,
248 \*(``@\*('' means equal to and
249 \*(``!\*('' inverts the sense of the test.
250 The baud rate is specified as a number and is compared with the speed
251 of the standard error output (which should be the control terminal).
252 The terminal type is a string.
253 .PP
254 If the terminal type is not specified on the command line, the \fB\-m\fP
255 mappings are applied to the terminal type.
256 If the port type and baud
257 rate match the mapping, the terminal type specified in the mapping
258 replaces the current type.
259 If more than one mapping is specified, the
260 first applicable mapping is used.
261 .PP
262 For example, consider the following mapping: \fBdialup>9600:vt100\fP.
263 The port type is dialup , the operator is >, the baud rate
264 specification is 9600, and the terminal type is vt100.
265 The result of
266 this mapping is to specify that if the terminal type is \fBdialup\fP,
267 and the baud rate is greater than 9600 baud, a terminal type of
268 \fBvt100\fP will be used.
269 .PP
270 If no baud rate is specified, the terminal type will match any baud rate.
271 If no port type is specified, the terminal type will match any port type.
272 For example, \fB\-m dialup:vt100 \-m :?xterm\fP
273 will cause any dialup port, regardless of baud rate, to match the terminal
274 type vt100, and any non-dialup port type to match the terminal type ?xterm.
275 Note, because of the leading question mark, the user will be
276 queried on a default port as to whether they are actually using an xterm
277 terminal.
278 .PP
279 No whitespace characters are permitted in the \fB\-m\fP option argument.
280 Also, to avoid problems with meta-characters, it is suggested that the
281 entire \fB\-m\fP option argument be placed within single quote characters,
282 and that \fBcsh\fP users insert a backslash character (\*(``\e\*('') before
283 any exclamation marks (\*(``!\*('').
284 .SH HISTORY
285 A \fBreset\fP command appeared in 1BSD (March 1978), written by Kurt Shoens.
286 This program set the \fIerase\fP and \fIkill\fP characters
287 to \fB^H\fP (backspace) and \fB@\fP respectively.
288 Mark Horton improved that in 3BSD (October 1979), adding
289 \fIintr\fP, \fIquit\fP, \fIstart\fP/\fIstop\fP and \fIeof\fP characters
290 as well as changing the program to avoid modifying any user settings.
291 That version of \fBreset\fP did not use the termcap database.
292 .PP
293 A separate \fBtset\fP command was provided in 1BSD by Eric Allman,
294 using the termcap database.
295 Allman's comments in the source code indicate
296 that he began work in October 1977,
297 continuing development over the next few years.
298 .PP
299 According to comments in the source code,
300 the \fBtset\fP program was modified in September 1980,
301 to use logic copied from the 3BSD \*(``reset\*(''
302 when it was invoked as \fBreset\fP.
303 This version appeared in 4.1cBSD, late in 1982.
304 .PP
305 Other developers (e.g., Keith Bostic and Jim Bloom)
306 continued to modify \fBtset\fP until 4.4BSD was released in 1993.
307 .PP
308 The \fBncurses\fP implementation
309 was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
310 S. Raymond <esr@snark.thyrsus.com>.
311 .SH COMPATIBILITY
312 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
313 (POSIX.1-2008) nor
314 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
315 .PP
316 The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
317 incorporated the terminal-mode manipulation as well as termcap-based features
318 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
319 presumably with the intention of making \fBtset\fP obsolete.
320 However, each of those systems still provides \fBtset\fP.
321 In fact, the commonly-used \fBreset\fP utility
322 is always an alias for \fBtset\fP.
323 .PP
324 The \fB@TSET@\fP utility provides for backward-compatibility with BSD
325 environments (under most modern UNIXes, \fB/etc/inittab\fP and \fBgetty\fP(1)
326 can set \fBTERM\fP appropriately for each dial-up line; this obviates what was
327 \fB@TSET@\fP's most important use).
328 This implementation behaves like 4.4BSD
329 \fBtset\fP, with a few exceptions specified here.
330 .PP
331 A few options are different
332 because the \fBTERMCAP\fP variable
333 is no longer supported under terminfo-based \fBncurses\fP:
334 .bP
335 The \fB\-S\fP option of BSD \fBtset\fP no longer works;
336 it prints an error message to the standard error and dies.
337 .bP
338 The \fB\-s\fP option only sets \fBTERM\fP, not \fBTERMCAP\fP.
339 .PP
340 There was an undocumented 4.4BSD feature
341 that invoking \fBtset\fP via a link named
342 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
343 set the terminal to use upper-case only.
344 This feature has been omitted.
345 .PP
346 The \fB\-A\fP, \fB\-E\fP, \fB\-h\fP, \fB\-u\fP and \fB\-v\fP
347 options were deleted from the \fB@TSET@\fP
348 utility in 4.4BSD.
349 None of them were documented in 4.3BSD and all are
350 of limited utility at best.
351 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options are similarly
352 not documented or useful, but were retained as they appear to be in
353 widespread use.
354 It is strongly recommended that any usage of these
355 three options be changed to use the \fB\-m\fP option instead.
356 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fP options
357 are therefore omitted from the usage summary above.
358 .PP
359 Very old systems, e.g., 3BSD, used a different terminal driver which
360 was replaced in 4BSD in the early 1980s.
361 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
362 \fB\-n\fP option to specify that the new terminal driver should be used.
363 This implementation does not provide that choice.
364 .PP
365 It is still permissible to specify the \fB\-e\fP, \fB\-i\fP,
366 and \fB\-k\fP options without arguments,
367 although it is strongly recommended that such usage be fixed to
368 explicitly specify the character.
369 .PP
370 As of 4.4BSD,
371 executing \fB@TSET@\fP as \fB@RESET@\fP no longer implies the \fB\-Q\fP option.
372 Also, the interaction between the \- option and the \fIterminal\fP
373 argument in some historic implementations of \fB@TSET@\fP has been removed.
374 .PP
375 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
376 However, a different window size-change feature was provided in 4.4BSD.
377 .bP
378 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
379 to set the window size if \fBtset\fP is not able to obtain the window
380 size from the operating system.
381 .bP
382 In ncurses, \fB@TSET@\fP obtains the window size using
383 \fBsetupterm\fP, which may be from
384 the operating system,
385 the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
386 the terminal description.
387 .PP
388 Obtaining the window size from the terminal description is common to
389 both implementations, but considered obsolescent.
390 Its only practical use is for hardware terminals.
391 Generally speaking, a window size would be unset only if there were
392 some problem obtaining the value from the operating system
393 (and \fBsetupterm\fP would still fail).
394 For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
395 may be useful for working around window-size problems.
396 Those have the drawback that if the window is resized,
397 those variables must be recomputed and reassigned.
398 To do this more easily, use the \fBresize\fP(1) program.
399 .SH ENVIRONMENT
400 The \fB@TSET@\fP command uses these environment variables:
401 .TP 5
402 SHELL
403 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP(1) or
404 \fBcsh\fP(1) syntax.
405 .TP 5
406 TERM
407 Denotes your terminal type.
408 Each terminal type is distinct, though many are similar.
409 .TP 5
410 TERMCAP
411 may denote the location of a termcap database.
412 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
413 \fB@TSET@\fP removes the variable from the environment before looking
414 for the terminal description.
415 .SH FILES
416 .TP 5
417 /etc/ttys
418 system port name to terminal type mapping database (BSD versions only).
419 .TP
420 @TERMINFO@
421 terminal capability database
422 .SH SEE ALSO
423 .hy 0
424 \fBcsh\fP(1),
425 \fBsh\fP(1),
426 \fBstty\fP(1),
427 \fBcurs_terminfo\fP(3X),
428 \fBtty\fP(4),
429 \fBterminfo\fP(5),
430 \fBttys\fP(5),
431 \fBenviron\fP(7)
432 .hy
433 .PP
434 This describes \fBncurses\fP
435 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).