2 ****************************************************************************
3 * Copyright 2018-2022,2023 Thomas E. Dickey *
4 * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: tset.1,v 1.72 2023/10/07 21:19:07 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>tset 1 2023-10-07 ncurses 6.4 User commands</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">tset 1 2023-10-07 ncurses 6.4 User commands</H1>
44 <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG> User commands <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>tset</STRONG>, <STRONG>reset</STRONG> - initialize or reset terminal state
53 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
54 <STRONG>tset</STRONG> [<STRONG>-IQVcqrsw</STRONG>] [<STRONG>-</STRONG>] [<STRONG>-e</STRONG> <EM>ch</EM>] [<STRONG>-i</STRONG> <EM>ch</EM>] [<STRONG>-k</STRONG> <EM>ch</EM>] [<STRONG>-m</STRONG> <EM>mapping</EM>] [<EM>terminal</EM>]
55 <STRONG>reset</STRONG> [<STRONG>-IQVcqrsw</STRONG>] [<STRONG>-</STRONG>] [<STRONG>-e</STRONG> <EM>ch</EM>] [<STRONG>-i</STRONG> <EM>ch</EM>] [<STRONG>-k</STRONG> <EM>ch</EM>] [<STRONG>-m</STRONG> <EM>mapping</EM>] [<EM>terminal</EM>]
58 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
60 </PRE><H3><a name="h3-tset---initialization">tset - initialization</a></H3><PRE>
61 This program initializes terminals.
63 First, <STRONG>tset</STRONG> retrieves the current terminal mode settings for your
64 terminal. It does this by successively testing
66 <STRONG>o</STRONG> the standard error,
68 <STRONG>o</STRONG> standard output,
70 <STRONG>o</STRONG> standard input and
72 <STRONG>o</STRONG> ultimately "/dev/tty"
74 to obtain terminal settings. Having retrieved these settings, <STRONG>tset</STRONG>
75 remembers which file descriptor to use when updating settings.
77 Next, <STRONG>tset</STRONG> determines the type of terminal that you are using. This
78 determination is done as follows, using the first terminal type found.
80 1. The <STRONG>terminal</STRONG> argument specified on the command line.
82 2. The value of the <STRONG>TERM</STRONG> environmental variable.
84 3. (BSD systems only.) The terminal type associated with the standard
85 error output device in the <EM>/etc/ttys</EM> file. (On System-V-like UNIXes
86 and systems using that convention, <STRONG>getty(1)</STRONG> does this job by setting
87 <STRONG>TERM</STRONG> according to the type passed to it by <EM>/etc/inittab</EM>.)
89 4. The default terminal type, "unknown", is not suitable for curses
92 If the terminal type was not specified on the command-line, the <STRONG>-m</STRONG>
93 option mappings are then applied (see the section <STRONG>TERMINAL</STRONG> <STRONG>TYPE</STRONG> <STRONG>MAPPING</STRONG>
94 for more information). Then, if the terminal type begins with a
95 question mark ("?"), the user is prompted for confirmation of the
96 terminal type. An empty response confirms the type, or, another type
97 can be entered to specify a new type. Once the terminal type has been
98 determined, the terminal description for the terminal is retrieved. If
99 no terminal description is found for the type, the user is prompted for
100 another terminal type.
102 Once the terminal description is retrieved,
104 <STRONG>o</STRONG> if the "<STRONG>-w</STRONG>" option is enabled, <STRONG>tset</STRONG> may update the terminal's
107 If the window size cannot be obtained from the operating system,
108 but the terminal description (or environment, e.g., <STRONG>LINES</STRONG> and
109 <STRONG>COLUMNS</STRONG> variables specify this), use this to set the operating
110 system's notion of the window size.
112 <STRONG>o</STRONG> if the "<STRONG>-c</STRONG>" option is enabled, the backspace, interrupt and line
113 kill characters (among many other things) are set
115 <STRONG>o</STRONG> unless the "<STRONG>-I</STRONG>" option is enabled, the terminal and tab
116 <EM>initialization</EM> strings are sent to the standard error output, and
117 <STRONG>tset</STRONG> waits one second (in case a hardware reset was issued).
119 <STRONG>o</STRONG> Finally, if the erase, interrupt and line kill characters have
120 changed, or are not set to their default values, their values are
121 displayed to the standard error output.
124 </PRE><H3><a name="h3-reset---reinitialization">reset - reinitialization</a></H3><PRE>
125 When invoked as <STRONG>reset</STRONG>, <STRONG>tset</STRONG> sets the terminal modes to "sane" values:
127 <STRONG>o</STRONG> sets cooked and echo modes,
129 <STRONG>o</STRONG> turns off cbreak and raw modes,
131 <STRONG>o</STRONG> turns on newline translation and
133 <STRONG>o</STRONG> resets any unset special characters to their default values
135 before doing the terminal initialization described above. Also, rather
136 than using the terminal <EM>initialization</EM> strings, it uses the terminal
137 <EM>reset</EM> strings.
139 The <STRONG>reset</STRONG> command is useful after a program dies leaving a terminal in
142 <STRONG>o</STRONG> you may have to type
144 <EM><LF></EM><STRONG>reset</STRONG><EM><LF></EM>
146 (the line-feed character is normally control-J) to get the terminal
147 to work, as carriage-return may no longer work in the abnormal
150 <STRONG>o</STRONG> Also, the terminal will often not echo the command.
153 </PRE><H2><a name="h2-OPTIONS">OPTIONS</a></H2><PRE>
154 The options are as follows:
156 <STRONG>-c</STRONG> Set control characters and modes.
158 <STRONG>-e</STRONG> <EM>ch</EM>
159 Set the erase character to <EM>ch</EM>.
161 <STRONG>-I</STRONG> Do not send the terminal or tab initialization strings to the
164 <STRONG>-i</STRONG> <EM>ch</EM>
165 Set the interrupt character to <EM>ch</EM>.
167 <STRONG>-k</STRONG> <EM>ch</EM>
168 Set the line kill character to <EM>ch</EM>.
170 <STRONG>-m</STRONG> <EM>mapping</EM>
171 Specify a mapping from a port type to a terminal. See the section
172 <STRONG>TERMINAL</STRONG> <STRONG>TYPE</STRONG> <STRONG>MAPPING</STRONG> for more information.
174 <STRONG>-Q</STRONG> Do not display any values for the erase, interrupt and line kill
175 characters. Normally <STRONG>tset</STRONG> displays the values for control
176 characters which differ from the system's default values.
178 <STRONG>-q</STRONG> The terminal type is displayed to the standard output, and the
179 terminal is not initialized in any way. The option "-" by itself
180 is equivalent but archaic.
182 <STRONG>-r</STRONG> Print the terminal type to the standard error output.
184 <STRONG>-s</STRONG> Print the sequence of shell commands to initialize the environment
185 variable <STRONG>TERM</STRONG> to the standard output. See the section <STRONG>SETTING</STRONG> <STRONG>THE</STRONG>
186 <STRONG>ENVIRONMENT</STRONG> for details.
188 <STRONG>-V</STRONG> reports the version of ncurses which was used in this program, and
191 <STRONG>-w</STRONG> Resize the window to match the size deduced via <STRONG><A HREF="curs_terminfo.3x.html">setupterm(3x)</A></STRONG>.
192 Normally this has no effect, unless <STRONG>setupterm</STRONG> is not able to
193 detect the window size.
195 The arguments for the <STRONG>-e</STRONG>, <STRONG>-i</STRONG>, and <STRONG>-k</STRONG> options may either be entered as
196 actual characters or by using the "hat" notation, i.e., control-h may
197 be specified as "^H" or "^h".
199 If neither <STRONG>-c</STRONG> or <STRONG>-w</STRONG> is given, both options are assumed.
202 </PRE><H2><a name="h2-SETTING-THE-ENVIRONMENT">SETTING THE ENVIRONMENT</a></H2><PRE>
203 It is often desirable to enter the terminal type and information about
204 the terminal's capabilities into the shell's environment. This is done
205 using the <STRONG>-s</STRONG> option.
207 When the <STRONG>-s</STRONG> option is specified, the commands to enter the information
208 into the shell's environment are written to the standard output. If
209 the <STRONG>SHELL</STRONG> environmental variable ends in "csh", the commands are for
210 <STRONG>csh</STRONG>, otherwise, they are for <STRONG>sh(1)</STRONG>. Note, the <STRONG>csh</STRONG> commands set and
211 unset the shell variable <STRONG>noglob</STRONG>, leaving it unset. The following line
212 in the <STRONG>.login</STRONG> or <STRONG>.profile</STRONG> files will initialize the environment
215 eval `tset -s options ... `
218 </PRE><H2><a name="h2-TERMINAL-TYPE-MAPPING">TERMINAL TYPE MAPPING</a></H2><PRE>
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 <EM>/etc/ttys</EM> file or the <STRONG>TERM</STRONG> environmental variable is often something
222 generic like <STRONG>network</STRONG>, <STRONG>dialup</STRONG>, or <STRONG>unknown</STRONG>. When <STRONG>tset</STRONG> is used in a
223 startup script it is often desirable to provide information about the
224 type of terminal used on such ports.
226 The <STRONG>-m</STRONG> options maps from some set of conditions to a terminal type,
227 that is, to tell <STRONG>tset</STRONG> "If I'm on this port at a particular speed, guess
228 that I'm on that kind of terminal".
230 The argument to the <STRONG>-m</STRONG> option consists of an optional port type, an
231 optional operator, an optional baud rate specification, an optional
232 colon (":") character and a terminal type. The port type is a string
233 (delimited by either the operator or the colon character). The
234 operator may be any combination of ">", "<", "@", and "!"; ">" means
235 greater than, "<" means less than, "@" means equal to and "!" inverts
236 the sense of the test. The baud rate is specified as a number and is
237 compared with the speed of the standard error output (which should be
238 the control terminal). The terminal type is a string.
240 If the terminal type is not specified on the command line, the <STRONG>-m</STRONG>
241 mappings are applied to the terminal type. If the port type and baud
242 rate match the mapping, the terminal type specified in the mapping
243 replaces the current type. If more than one mapping is specified, the
244 first applicable mapping is used.
246 For example, consider the following mapping: <STRONG>dialup>9600:vt100</STRONG>. The
247 port type is dialup , the operator is >, the baud rate specification is
248 9600, and the terminal type is vt100. The result of this mapping is to
249 specify that if the terminal type is <STRONG>dialup</STRONG>, and the baud rate is
250 greater than 9600 baud, a terminal type of <STRONG>vt100</STRONG> will be used.
252 If no baud rate is specified, the terminal type will match any baud
253 rate. If no port type is specified, the terminal type will match any
254 port type. For example, <STRONG>-m</STRONG> <STRONG>dialup:vt100</STRONG> <STRONG>-m</STRONG> <STRONG>:?xterm</STRONG> will cause any
255 dialup port, regardless of baud rate, to match the terminal type vt100,
256 and any non-dialup port type to match the terminal type ?xterm. Note,
257 because of the leading question mark, the user will be queried on a
258 default port as to whether they are actually using an xterm terminal.
260 No whitespace characters are permitted in the <STRONG>-m</STRONG> option argument.
261 Also, to avoid problems with meta-characters, it is suggested that the
262 entire <STRONG>-m</STRONG> option argument be placed within single quote characters, and
263 that <STRONG>csh</STRONG> users insert a backslash character ("\") before any
264 exclamation marks ("!").
267 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
268 A <STRONG>reset</STRONG> command appeared in 1BSD (March 1978), written by Kurt Shoens.
269 This program set the <EM>erase</EM> and <EM>kill</EM> characters to <STRONG>^H</STRONG> (backspace) and <STRONG>@</STRONG>
270 respectively. Mark Horton improved that in 3BSD (October 1979), adding
271 <EM>intr</EM>, <EM>quit</EM>, <EM>start</EM>/<EM>stop</EM> and <EM>eof</EM> characters as well as changing the
272 program to avoid modifying any user settings. That version of <STRONG>reset</STRONG>
273 did not use the termcap database.
275 A separate <STRONG>tset</STRONG> command was provided in 1BSD by Eric Allman, using the
276 termcap database. Allman's comments in the source code indicate that
277 he began work in October 1977, continuing development over the next few
280 According to comments in the source code, the <STRONG>tset</STRONG> program was modified
281 in September 1980, to use logic copied from the 3BSD "reset" when it
282 was invoked as <STRONG>reset</STRONG>. This version appeared in 4.1cBSD, late in 1982.
284 Other developers (e.g., Keith Bostic and Jim Bloom) continued to modify
285 <STRONG>tset</STRONG> until 4.4BSD was released in 1993.
287 The <STRONG>ncurses</STRONG> implementation was lightly adapted from the 4.4BSD sources
288 for a terminfo environment by Eric S. Raymond <esr@snark.thyrsus.com>.
291 </PRE><H2><a name="h2-COMPATIBILITY">COMPATIBILITY</a></H2><PRE>
292 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
293 (POSIX.1-2008) nor X/Open Curses Issue 7 documents <STRONG>tset</STRONG> or <STRONG>reset</STRONG>.
295 The AT&T <STRONG>tput</STRONG> utility (AIX, HPUX, Solaris) incorporated the terminal-
296 mode manipulation as well as termcap-based features such as resetting
297 tabstops from <STRONG>tset</STRONG> in BSD (4.1c), presumably with the intention of
298 making <STRONG>tset</STRONG> obsolete. However, each of those systems still provides
299 <STRONG>tset</STRONG>. In fact, the commonly-used <STRONG>reset</STRONG> utility is always an alias for
300 <STRONG>tset</STRONG>.
302 The <STRONG>tset</STRONG> utility provides for backward-compatibility with BSD
303 environments (under most modern UNIXes, <STRONG>/etc/inittab</STRONG> and <STRONG>getty(1)</STRONG> can
304 set <STRONG>TERM</STRONG> appropriately for each dial-up line; this obviates what was
305 <STRONG>tset</STRONG>'s most important use). This implementation behaves like 4.4BSD
306 <STRONG>tset</STRONG>, with a few exceptions specified here.
308 A few options are different because the <STRONG>TERMCAP</STRONG> variable is no longer
309 supported under terminfo-based <STRONG>ncurses</STRONG>:
311 <STRONG>o</STRONG> The <STRONG>-S</STRONG> option of BSD <STRONG>tset</STRONG> no longer works; it prints an error
312 message to the standard error and dies.
314 <STRONG>o</STRONG> The <STRONG>-s</STRONG> option only sets <STRONG>TERM</STRONG>, not <STRONG>TERMCAP</STRONG>.
316 There was an undocumented 4.4BSD feature that invoking <STRONG>tset</STRONG> via a link
317 named "TSET" (or via any other name beginning with an upper-case
318 letter) set the terminal to use upper-case only. This feature has been
321 The <STRONG>-A</STRONG>, <STRONG>-E</STRONG>, <STRONG>-h</STRONG>, <STRONG>-u</STRONG> and <STRONG>-v</STRONG> options were deleted from the <STRONG>tset</STRONG> utility in
322 4.4BSD. None of them were documented in 4.3BSD and all are of limited
323 utility at best. The <STRONG>-a</STRONG>, <STRONG>-d</STRONG>, and <STRONG>-p</STRONG> options are similarly not
324 documented or useful, but were retained as they appear to be in
325 widespread use. It is strongly recommended that any usage of these
326 three options be changed to use the <STRONG>-m</STRONG> option instead. The <STRONG>-a</STRONG>, <STRONG>-d</STRONG>, and
327 <STRONG>-p</STRONG> options are therefore omitted from the usage summary above.
329 Very old systems, e.g., 3BSD, used a different terminal driver which
330 was replaced in 4BSD in the early 1980s. To accommodate these older
331 systems, the 4BSD <STRONG>tset</STRONG> provided a <STRONG>-n</STRONG> option to specify that the new
332 terminal driver should be used. This implementation does not provide
335 It is still permissible to specify the <STRONG>-e</STRONG>, <STRONG>-i</STRONG>, and <STRONG>-k</STRONG> options without
336 arguments, although it is strongly recommended that such usage be fixed
337 to explicitly specify the character.
339 As of 4.4BSD, executing <STRONG>tset</STRONG> as <STRONG>reset</STRONG> no longer implies the <STRONG>-Q</STRONG> option.
340 Also, the interaction between the - option and the <EM>terminal</EM> argument in
341 some historic implementations of <STRONG>tset</STRONG> has been removed.
343 The <STRONG>-c</STRONG> and <STRONG>-w</STRONG> options are not found in earlier implementations.
344 However, a different window size-change feature was provided in 4.4BSD.
346 <STRONG>o</STRONG> In 4.4BSD, <STRONG>tset</STRONG> uses the window size from the termcap description
347 to set the window size if <STRONG>tset</STRONG> is not able to obtain the window
348 size from the operating system.
350 <STRONG>o</STRONG> In ncurses, <STRONG>tset</STRONG> obtains the window size using <STRONG>setupterm</STRONG>, which may
351 be from the operating system, the <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG> environment
352 variables or the terminal description.
354 Obtaining the window size from the terminal description is common to
355 both implementations, but considered obsolescent. Its only practical
356 use is for hardware terminals. Generally speaking, a window size would
357 be unset only if there were some problem obtaining the value from the
358 operating system (and <STRONG>setupterm</STRONG> would still fail). For that reason,
359 the <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG> environment variables may be useful for working
360 around window-size problems. Those have the drawback that if the
361 window is resized, those variables must be recomputed and reassigned.
362 To do this more easily, use the <STRONG>resize(1)</STRONG> program.
365 </PRE><H2><a name="h2-ENVIRONMENT">ENVIRONMENT</a></H2><PRE>
366 The <STRONG>tset</STRONG> command uses these environment variables:
369 tells <STRONG>tset</STRONG> whether to initialize <STRONG>TERM</STRONG> using <STRONG>sh(1)</STRONG> or <STRONG>csh(1)</STRONG>
372 TERM Denotes your terminal type. Each terminal type is distinct,
373 though many are similar.
376 may denote the location of a termcap database. If it is not an
377 absolute pathname, e.g., begins with a "/", <STRONG>tset</STRONG> removes the
378 variable from the environment before looking for the terminal
382 </PRE><H2><a name="h2-FILES">FILES</a></H2><PRE>
384 system port name to terminal type mapping database (BSD versions
388 terminal capability database
391 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
392 <STRONG>csh(1)</STRONG>, <STRONG>sh(1)</STRONG>, <STRONG>stty(1)</STRONG>, <STRONG><A HREF="curs_terminfo.3x.html">curs_terminfo(3x)</A></STRONG>, <STRONG>tty(4)</STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>,
393 <STRONG>ttys(5)</STRONG>, <STRONG>environ(7)</STRONG>
397 ncurses 6.4 2023-10-07 <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
401 <li><a href="#h2-NAME">NAME</a></li>
402 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
403 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
405 <li><a href="#h3-tset---initialization">tset - initialization</a></li>
406 <li><a href="#h3-reset---reinitialization">reset - reinitialization</a></li>
409 <li><a href="#h2-OPTIONS">OPTIONS</a></li>
410 <li><a href="#h2-SETTING-THE-ENVIRONMENT">SETTING THE ENVIRONMENT</a></li>
411 <li><a href="#h2-TERMINAL-TYPE-MAPPING">TERMINAL TYPE MAPPING</a></li>
412 <li><a href="#h2-HISTORY">HISTORY</a></li>
413 <li><a href="#h2-COMPATIBILITY">COMPATIBILITY</a></li>
414 <li><a href="#h2-ENVIRONMENT">ENVIRONMENT</a></li>
415 <li><a href="#h2-FILES">FILES</a></li>
416 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>