]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/tset.1
ncurses 6.0 - patch 20170107
[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.47 2017/01/07 22:59:51 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 (1979), written by Kurt Shoens.
278 .PP
279 A separate \fBtset\fP command was provided in 2BSD by Eric Allman.
280 While the oldest published source (from 1979) provides both programs,
281 Allman's comments in the 2BSD source code indicate
282 that he began work in October 1977,
283 continuing development over the next few years.
284 .PP
285 In September 1980, Eric Allman modified \fBtset\fP to provide a \*(lqreset\*(rq
286 feature when the program was invoked as \fBreset\fP.
287 This version appeared in 4.1cBSD, late in 1982.
288 .PP
289 The \fBncurses\fR implementation
290 was lightly adapted from the 4.4BSD sources for a terminfo environment by Eric
291 S. Raymond <esr@snark.thyrsus.com>.
292 .SH COMPATIBILITY
293 .PP
294 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
295 (POSIX.1-2008) nor
296 X/Open Curses Issue 7 documents \fB@TSET@\fP or \fB@RESET@\fP.
297 .PP
298 The AT&T \fBtput\fP utility (AIX, HPUX, Solaris)
299 incorporated the terminal-mode manipulation as well as termcap-based features
300 such as resetting tabstops from \fBtset\fP in BSD (4.1c),
301 presumably with the intention of making \fBtset\fP obsolete.
302 However, each of those systems still provides \fBtset\fP.
303 In fact, the commonly-used \fBreset\fP utility
304 is always an alias for \fBtset\fP.
305 .PP
306 The \fB@TSET@\fR utility provides for backward-compatibility with BSD
307 environments (under most modern UNIXes, \fB/etc/inittab\fR and \fIgetty\fR(1)
308 can set \fBTERM\fR appropriately for each dial-up line; this obviates what was
309 \fB@TSET@\fR's most important use).  This implementation behaves like 4.4BSD
310 \fBtset\fP, with a few exceptions specified here.
311 .PP
312 A few options are different
313 because the \fBTERMCAP\fR variable
314 is no longer supported under terminfo-based \fBncurses\fR:
315 .bP
316 The \fB\-S\fR option of BSD \fBtset\fP no longer works;
317 it prints an error message to the standard error and dies.
318 .bP
319 The \fB\-s\fR option only sets \fBTERM\fR, not \fBTERMCAP\fP.
320 .PP
321 There was an undocumented 4.4BSD feature
322 that invoking \fBtset\fP via a link named
323 \*(``TSET\*('' (or via any other name beginning with an upper-case letter)
324 set the terminal to use upper-case only.
325 This feature has been omitted.
326 .PP
327 The \fB\-A\fR, \fB\-E\fR, \fB\-h\fR, \fB\-u\fR and \fB\-v\fR
328 options were deleted from the \fB@TSET@\fR
329 utility in 4.4BSD.
330 None of them were documented in 4.3BSD and all are
331 of limited utility at best.
332 The \fB\-a\fR, \fB\-d\fR, and \fB\-p\fR options are similarly
333 not documented or useful, but were retained as they appear to be in
334 widespread use.  It is strongly recommended that any usage of these
335 three options be changed to use the \fB\-m\fR option instead.
336 The \fB\-a\fP, \fB\-d\fP, and \fB\-p\fR options are therefore omitted from the usage summary above.
337 .PP
338 Very old systems, e.g., 3BSD, used a different terminal driver which
339 was replaced in 4BSD in the early 1980s.
340 To accommodate these older systems, the 4BSD \fB@TSET@\fP provided a
341 \fB\-n\fP option to specify that the new terminal driver should be used.
342 This implementation does not provide that choice.
343 .PP
344 It is still permissible to specify the \fB\-e\fR, \fB\-i\fR,
345 and \fB\-k\fR options without arguments,
346 although it is strongly recommended that such usage be fixed to
347 explicitly specify the character.
348 .PP
349 As of 4.4BSD,
350 executing \fB@TSET@\fR as \fB@RESET@\fR no longer implies the \fB\-Q\fR option.
351 Also, the interaction between the \- option and the \fIterminal\fR
352 argument in some historic implementations of \fB@TSET@\fR has been removed.
353 .PP
354 The \fB\-c\fP and \fB\-w\fP options are not found in earlier implementations.
355 However, a different window size-change feature was provided in 4.4BSD.
356 .bP
357 In 4.4BSD, \fBtset\fP uses the window size from the termcap description
358 to set the window size if \fBtset\fP is not able to obtain the window
359 size from the operating system.
360 .bP
361 In ncurses, \fB@TSET@\fR obtains the window size using
362 \fBsetupterm\fP, which may be from
363 the operating system,
364 the \fBLINES\fP and \fBCOLUMNS\fP environment variables or
365 the terminal description.
366 .PP
367 Obtaining the window size from the terminal description is common to
368 both implementations, but considered obsolescent.
369 Its only practical use is for hardware terminals.
370 Generally speaking, a window size would be unset only if there were
371 some problem obtaining the value from the operating system
372 (and \fBsetupterm\fP would still fail).
373 For that reason, the \fBLINES\fP and \fBCOLUMNS\fP environment variables
374 may be useful for working around window-size problems.
375 Those have the drawback that if the window is resized,
376 those variables must be recomputed and reassigned.
377 To do this more easily, use the \fBresize\fP(1) program.
378 .SH ENVIRONMENT
379 The \fB@TSET@\fR command uses these environment variables:
380 .TP 5
381 SHELL
382 tells \fB@TSET@\fP whether to initialize \fBTERM\fP using \fBsh\fP or
383 \fBcsh\fP syntax.
384 .TP 5
385 TERM
386 Denotes your terminal type.
387 Each terminal type is distinct, though many are similar.
388 .TP 5
389 TERMCAP
390 may denote the location of a termcap database.
391 If it is not an absolute pathname, e.g., begins with a \*(``/\*('',
392 \fB@TSET@\fP removes the variable from the environment before looking
393 for the terminal description.
394 .SH FILES
395 .TP 5
396 /etc/ttys
397 system port name to terminal type mapping database (BSD versions only).
398 .TP
399 @TERMINFO@
400 terminal capability database
401 .SH SEE ALSO
402 .hy 0
403 csh(1),
404 sh(1),
405 stty(1),
406 curs_terminfo(3X),
407 tty(4),
408 terminfo(5),
409 ttys(5),
410 environ(7)
411 .hy
412 .PP
413 This describes \fBncurses\fR
414 version @NCURSES_MAJOR@.@NCURSES_MINOR@ (patch @NCURSES_PATCH@).