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