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