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