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