]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.1 - patch 20180127
[ncurses.git] / man / tset.1
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2016,2017 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.52 2017/11/20 01:27:53 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 (among many other things) are set
105 .bP
106 unless the \*(``\fB\-I\fP\*('' option is enabled,
107 the terminal
108 and tab \fIinitialization\fP strings are sent to the standard error output,
109 and \fB@TSET@\fP waits one second (in case a hardware reset was issued).
110 .bP
111 Finally, if the erase, interrupt and line kill characters have changed,
112 or are not set to their default values, their values are displayed to the
113 standard error output.
114 .SS reset - reinitialization
115 .PP
116 When invoked as \fB@RESET@\fR, \fB@TSET@\fR sets the terminal
117 modes to \*(``sane\*('' values:
118 .bP
119 sets cooked and echo modes,
120 .bP
121 turns off cbreak and raw modes,
122 .bP
123 turns on newline translation and
124 .bP
125 resets any unset special characters to their default values
126 .PP
127 before
128 doing the terminal initialization described above.
129 Also, rather than using the terminal \fIinitialization\fP strings,
130 it uses the terminal \fIreset\fP strings.
131 .PP
132 The \fB@RESET@\fP command is useful
133 after a program dies leaving a terminal in an abnormal state:
134 .bP
135 you may have to type
136 .sp
137     \fI<LF>\fP\fB@RESET@\fP\fI<LF>\fP
138 .sp
139 (the line-feed character is normally control-J) to get the terminal
140 to work, as carriage-return may no longer work in the abnormal state.
141 .bP
142 Also, the terminal will often not echo the command.
143 .SH OPTIONS 
144 .PP
145 The options are as follows:
146 .TP 5
147 .B \-c
148 Set control characters and modes.
149 .TP 5
150 .B \-e
151 Set the erase character to \fIch\fR.
152 .TP
153 .B \-I
154 Do not send the terminal or tab initialization strings to the terminal.
155 .TP
156 .B \-i
157 Set the interrupt character to \fIch\fR.
158 .TP
159 .B \-k
160 Set the line kill character to \fIch\fR.
161 .TP
162 .B \-m
163 Specify a mapping from a port type to a terminal.
164 See the section
165 .B TERMINAL TYPE MAPPING
166 for more information.
167 .TP
168 .B \-Q
169 Do not display any values for the erase, interrupt and line kill characters.
170 Normally \fB@TSET@\fR displays the values for control characters which
171 differ from the system's default values.
172 .TP
173 .B \-q
174 The terminal type is displayed to the standard output, and the terminal is
175 not initialized in any way.
176 The option \*(``\-\*('' by itself is equivalent but archaic.
177 .TP
178 .B \-r
179 Print the terminal type to the standard error output.
180 .TP
181 .B \-s
182 Print the sequence of shell commands to initialize the environment variable
183 \fBTERM\fR to the standard output.
184 See the section
185 .B SETTING THE ENVIRONMENT
186 for details.
187 .TP
188 .B \-V
189 reports the version of ncurses which was used in this program, and exits.
190 .TP
191 .B \-w
192 Resize the window to match the size deduced via \fBsetupterm\fP(3X).
193 Normally this has no effect,
194 unless \fBsetupterm\fP is not able to detect the window size.
195 .PP
196 The arguments for the \fB\-e\fR, \fB\-i\fR, and \fB\-k\fR
197 options may either be entered as actual characters
198 or by using the \*(``hat\*(''
199 notation, i.e., control-h may be specified as \*(``^H\*('' or \*(``^h\*(''.
200 .PP
201 If neither \fB\-c\fP or \fB\-w\fP is given, both options are assumed.
202 .
203 .SH SETTING THE ENVIRONMENT
204 It is often desirable to enter the terminal type and information about
205 the terminal's capabilities into the shell's environment.
206 This is done using the \fB\-s\fR option.
207 .PP
208 When the \fB\-s\fR option is specified, the commands to enter the information
209 into the shell's environment are written to the standard output.  If
210 the \fBSHELL\fR environmental variable ends in \*(``csh\*('', the commands
211 are for \fBcsh\fR, otherwise, they are for \fBsh\fR.
212 Note, the \fBcsh\fR commands set and unset the shell variable
213 \fBnoglob\fR, leaving it unset.  The following line in the \fB.login\fR
214 or \fB.profile\fR files will initialize the environment correctly:
215 .sp
216     eval \`@TSET@ \-s options ... \`
217 .
218 .SH TERMINAL TYPE MAPPING
219 When the terminal is not hardwired into the system (or the current
220 system information is incorrect) the terminal type derived from the
221 \fI/etc/ttys\fR file or the \fBTERM\fR environmental variable is often
222 something generic like \fBnetwork\fR, \fBdialup\fR, or \fBunknown\fR.
223 When \fB@TSET@\fR is used in a startup script it is often desirable to
224 provide information about the type of terminal used on such ports.
225 .PP
226 The \fB\-m\fR options maps
227 from some set of conditions to a terminal type, that is, to
228 tell \fB@TSET@\fR
229 \*(``If I'm on this port at a particular speed,
230 guess that I'm on that kind of terminal\*(''.
231 .PP
232 The argument to the \fB\-m\fR option consists of an optional port type, an
233 optional operator, an optional baud rate specification, an optional
234 colon (\*(``:\*('') character and a terminal type.  The port type is a
235 string (delimited by either the operator or the colon character).
236 The operator may be any combination of
237 \*(``>\*('',
238 \*(``<\*('',
239 \*(``@\*('',
240 and \*(``!\*('';
241 \*(``>\*('' means greater than,
242 \*(``<\*('' means less than,
243 \*(``@\*('' means equal to and
244 \*(``!\*('' inverts the sense of the test.
245 The baud rate is specified as a number and is compared with the speed
246 of the standard error output (which should be the control terminal).
247 The terminal type is a string.
248 .PP
249 If the terminal type is not specified on the command line, the \fB\-m\fR
250 mappings are applied to the terminal type.  If the port type and baud
251 rate match the mapping, the terminal type specified in the mapping
252 replaces the current type.  If more than one mapping is specified, the
253 first applicable mapping is used.
254 .PP
255 For example, consider the following mapping: \fBdialup>9600:vt100\fR.
256 The port type is dialup , the operator is >, the baud rate
257 specification is 9600, and the terminal type is vt100.  The result of
258 this mapping is to specify that if the terminal type is \fBdialup\fR,
259 and the baud rate is greater than 9600 baud, a terminal type of
260 \fBvt100\fR will be used.
261 .PP
262 If no baud rate is specified, the terminal type will match any baud rate.
263 If no port type is specified, the terminal type will match any port type.
264 For example, \fB\-m dialup:vt100 \-m :?xterm\fR
265 will cause any dialup port, regardless of baud rate, to match the terminal
266 type vt100, and any non-dialup port type to match the terminal type ?xterm.
267 Note, because of the leading question mark, the user will be
268 queried on a default port as to whether they are actually using an xterm
269 terminal.
270 .PP
271 No whitespace characters are permitted in the \fB\-m\fR option argument.
272 Also, to avoid problems with meta-characters, it is suggested that the
273 entire \fB\-m\fR option argument be placed within single quote characters,
274 and that \fBcsh\fR users insert a backslash character (\*(``\e\*('') before
275 any exclamation marks (\*(``!\*('').
276 .SH HISTORY
277 .PP
278 A \fBreset\fP command appeared in 2BSD (April 1979), written by Kurt Shoens.
279 This program set the \fIerase\fP and \fIkill\fP characters
280 to \fB^H\fP (backspace) and \fB@\fP respectively.
281 Mark Horton improved that in 3BSD (October 1979), adding
282 \fIintr\fP, \fIquit\fP, \fIstart\fP/\fIstop\fP and \fIeof\fP characters
283 as well as changing the program to avoid modifying any user settings.
284 .PP
285 Later in 4.1BSD (December 1980),
286 Mark Horton added a call to the \fBtset\fP program
287 using the \fB\-I\fP and \fB\-Q\fP options, i.e.,
288 using that to improve the terminal modes.
289 With those options,
290 that version of \fBreset\fP did not use the termcap database.
291 .PP
292 A separate \fBtset\fP command was provided in 2BSD by Eric Allman.
293 While the oldest published source (from 1979)
294 provides both \fBtset\fP and \fBreset\fP,
295 Allman's comments in the 2BSD source code indicate
296 that he began work in October 1977,
297 continuing development over the next few years.
298 .PP
299 In September 1980, Eric Allman modified \fBtset\fP,
300 adding the code from the existing \*(``reset\*(''
301 feature when \fBtset\fP was invoked as \fBreset\fP.
302 Rather than simply copying the existing program,
303 in this merged version, \fBtset\fP used the termcap database
304 to do additional (re)initialization of the terminal.
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).  This implementation behaves like 4.4BSD
331 \fBtset\fP, with a few exceptions specified here.
332 .PP
333 A few options are different
334 because the \fBTERMCAP\fR variable
335 is no longer supported under terminfo-based \fBncurses\fR:
336 .bP
337 The \fB\-S\fR option of BSD \fBtset\fP no longer works;
338 it prints an error message to the standard error and dies.
339 .bP
340 The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.
341 .PP
342 There was an undocumented 4.4BSD feature
343 that invoking \fBtset\fP via a link named
344 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
345 set the terminal to use upper-case only.
346 This feature has been omitted.
347 .PP
348 The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
349 options were deleted from the \fB@TSET@\fR
350 utility in 4.4BSD.
351 None of them were documented in 4.3BSD and all are
352 of limited utility at best.
353 The \fB\-a\fR, \fB\-d\fR, and \fB\-p\fR options are similarly
354 not documented or useful, but were retained as they appear to be in
355 widespread use.  It is strongly recommended that any usage of these
356 three options be changed to use the \fB\-m\fR option instead.
357 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fR options 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\fR, \fB\-i\fR,
366 and \fB\-k\fR 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@\fR as \fB@RESET@\fR no longer implies the \fB\-Q\fR option.
372 Also, the interaction between the \- option and the \fIterminal\fR
373 argument in some historic implementations of \fB@TSET@\fR 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@\fR 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@\fR command uses these environment variables:
401 .TP 5
402 SHELL
403 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP or
404 \fBcsh\fP 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\fR
435 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).