2 ****************************************************************************
3 * Copyright 2018-2023,2024 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.88 2024/06/08 20:51:12 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 2024-06-08 ncurses 6.5 User commands</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">tset 1 2024-06-08 ncurses 6.5 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>
56 <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>
60 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
62 </PRE><H3><a name="h3-tset----initialization"><EM>tset</EM> -- initialization</a></H3><PRE>
63 This program initializes terminals.
65 First, <STRONG>tset</STRONG> retrieves the current terminal mode settings for your
66 terminal. It does this by successively testing
68 <STRONG>o</STRONG> the standard error,
70 <STRONG>o</STRONG> standard output,
72 <STRONG>o</STRONG> standard input and
74 <STRONG>o</STRONG> ultimately "/dev/tty"
76 to obtain terminal settings. Having retrieved these settings, <STRONG>tset</STRONG>
77 remembers which file descriptor to use when updating settings.
79 Next, <STRONG>tset</STRONG> determines the type of terminal that you are using. This
80 determination is done as follows, using the first terminal type found.
82 1. The <STRONG>terminal</STRONG> argument specified on the command line.
84 2. The value of the <EM>TERM</EM> environment variable.
86 3. (BSD systems only.) The terminal type associated with the standard
87 error output device in the <EM>/etc/ttys</EM> file. (On System V hosts and
88 systems using that convention, <STRONG>getty(8)</STRONG> does this job by setting <EM>TERM</EM>
89 according to the type passed to it by <EM>/etc/inittab</EM>.)
91 4. The default terminal type, "unknown", is not suitable for curses
94 If the terminal type was not specified on the command-line, the <STRONG>-m</STRONG>
95 option mappings are then applied; see subsection "Terminal Type
96 Mapping". Then, if the terminal type begins with a question mark
97 ("?"), the user is prompted for confirmation of the terminal type. An
98 empty response confirms the type, or, another type can be entered to
99 specify a new type. Once the terminal type has been determined, the
100 terminal description for the terminal is retrieved. If no terminal
101 description is found for the type, the user is prompted for another
104 Once the terminal description is retrieved,
106 <STRONG>o</STRONG> if the "<STRONG>-w</STRONG>" option is enabled, <STRONG>tset</STRONG> may update the terminal's
109 If the window size cannot be obtained from the operating system,
110 but the terminal description (or environment, e.g., <EM>LINES</EM> and
111 <EM>COLUMNS</EM> variables specify this), use this to set the operating
112 system's notion of the window size.
114 <STRONG>o</STRONG> if the "<STRONG>-c</STRONG>" option is enabled, the backspace, interrupt and line
115 kill characters (among many other things) are set
117 <STRONG>o</STRONG> unless the "<STRONG>-I</STRONG>" option is enabled, the terminal and tab
118 <EM>initialization</EM> strings are sent to the standard error output, and,
119 if the terminal device does not appear to be a pseudoterminal (as
120 might be used by a terminal emulator program), <STRONG>tset</STRONG> waits one
121 second in case a hardware reset was issued.
123 <STRONG>o</STRONG> Finally, if the erase, interrupt and line kill characters have
124 changed, or are not set to their default values, their values are
125 displayed to the standard error output.
128 </PRE><H3><a name="h3-reset----reinitialization"><EM>reset</EM> -- reinitialization</a></H3><PRE>
129 When invoked as <STRONG>reset</STRONG>, <STRONG>tset</STRONG> sets the terminal modes to "sane" values:
131 <STRONG>o</STRONG> sets cooked and echo modes,
133 <STRONG>o</STRONG> turns off cbreak and raw modes,
135 <STRONG>o</STRONG> turns on newline translation and
137 <STRONG>o</STRONG> resets any unset special characters to their default values
139 before doing the terminal initialization described above. Also, rather
140 than using the terminal <EM>initialization</EM> strings, it uses the terminal
141 <EM>reset</EM> strings.
143 The <STRONG>reset</STRONG> command is useful after a program dies leaving a terminal in
146 <STRONG>o</STRONG> you may have to type
148 <EM><LF></EM><STRONG>reset</STRONG><EM><LF></EM>
150 (the line-feed character is normally control-J) to get the terminal
151 to work, as carriage-return may no longer work in the abnormal
154 <STRONG>o</STRONG> Also, the terminal will often not echo the command.
157 </PRE><H3><a name="h3-Setting-the-Environment">Setting the Environment</a></H3><PRE>
158 It is often desirable to enter the terminal type and information about
159 the terminal's capabilities into the shell's environment. This is done
160 using the <STRONG>-s</STRONG> option.
162 When the <STRONG>-s</STRONG> option is specified, the commands to enter the information
163 into the shell's environment are written to the standard output. If
164 the <EM>SHELL</EM> environment variable ends in "csh", the commands are for
165 <STRONG>csh(1)</STRONG>, otherwise, they are for <STRONG>sh(1)</STRONG>. The <EM>csh</EM> commands set and unset
166 the shell variable <STRONG>noglob</STRONG>, leaving it unset. The following line in the
167 <STRONG>.login</STRONG> or <STRONG>.profile</STRONG> files will initialize the environment correctly:
169 eval `tset -s options ... `
172 </PRE><H3><a name="h3-Terminal-Type-Mapping">Terminal Type Mapping</a></H3><PRE>
173 When the terminal is not hardwired into the system (or the current
174 system information is incorrect) the terminal type derived from the
175 <EM>/etc/ttys</EM> file or the <EM>TERM</EM> environment variable is often something
176 generic like <STRONG>network</STRONG>, <STRONG>dialup</STRONG>, or <STRONG>unknown</STRONG>. When <STRONG>tset</STRONG> is used in a
177 startup script it is often desirable to provide information about the
178 type of terminal used on such ports.
180 The <STRONG>-m</STRONG> options maps from some set of conditions to a terminal type,
181 that is, to tell <STRONG>tset</STRONG> "If I'm on this port at a particular speed, guess
182 that I'm on that kind of terminal".
184 The argument to the <STRONG>-m</STRONG> option consists of an optional port type, an
185 optional operator, an optional baud rate specification, an optional
186 colon (":") character and a terminal type. The port type is a string
187 (delimited by either the operator or the colon character). The
188 operator may be any combination of ">", "<", "@", and "!"; ">" means
189 greater than, "<" means less than, "@" means equal to and "!" inverts
190 the sense of the test. The baud rate is specified as a number and is
191 compared with the speed of the standard error output (which should be
192 the control terminal). The terminal type is a string.
194 If the terminal type is not specified on the command line, the <STRONG>-m</STRONG>
195 mappings are applied to the terminal type. If the port type and baud
196 rate match the mapping, the terminal type specified in the mapping
197 replaces the current type. If more than one mapping is specified, the
198 first applicable mapping is used.
200 For example, consider the following mapping: <STRONG>dialup>9600:vt100</STRONG>. The
201 port type is dialup , the operator is >, the baud rate specification is
202 9600, and the terminal type is vt100. The result of this mapping is to
203 specify that if the terminal type is <STRONG>dialup</STRONG>, and the baud rate is
204 greater than 9600 baud, a terminal type of <STRONG>vt100</STRONG> will be used.
206 If no baud rate is specified, the terminal type will match any baud
207 rate. If no port type is specified, the terminal type will match any
208 port type. For example, <STRONG>-m</STRONG> <STRONG>dialup:vt100</STRONG> <STRONG>-m</STRONG> <STRONG>:?xterm</STRONG> will cause any
209 dialup port, regardless of baud rate, to match the terminal type vt100,
210 and any non-dialup port type to match the terminal type ?xterm. Note,
211 because of the leading question mark, the user will be queried on a
212 default port as to whether they are actually using an xterm terminal.
214 No whitespace characters are permitted in the <STRONG>-m</STRONG> option argument.
215 Also, to avoid problems with meta-characters, it is suggested that the
216 entire <STRONG>-m</STRONG> option argument be placed within single quote characters, and
217 that <EM>csh</EM> users insert a backslash character ("\") before any
218 exclamation marks ("!").
221 </PRE><H2><a name="h2-OPTIONS">OPTIONS</a></H2><PRE>
222 The options are as follows:
224 <STRONG>-c</STRONG> Set control characters and modes.
226 <STRONG>-e</STRONG> <EM>ch</EM>
227 Set the erase character to <EM>ch</EM>.
229 <STRONG>-I</STRONG> Do not send the terminal or tab initialization strings to the
232 <STRONG>-i</STRONG> <EM>ch</EM>
233 Set the interrupt character to <EM>ch</EM>.
235 <STRONG>-k</STRONG> <EM>ch</EM>
236 Set the line kill character to <EM>ch</EM>.
238 <STRONG>-m</STRONG> <EM>mapping</EM>
239 Specify a mapping from a port type to a terminal; see subsection
240 "Terminal Type Mapping".
242 <STRONG>-Q</STRONG> Do not display any values for the erase, interrupt and line kill
243 characters. Normally <STRONG>tset</STRONG> displays the values for control
244 characters which differ from the system's default values.
246 <STRONG>-q</STRONG> The terminal type is displayed to the standard output, and the
247 terminal is not initialized in any way. The option "-" by itself
248 is equivalent but archaic.
250 <STRONG>-r</STRONG> Print the terminal type to the standard error output.
252 <STRONG>-s</STRONG> Print the sequence of shell commands to initialize the environment
253 variable <EM>TERM</EM> to the standard output; see subsection "Setting the
256 <STRONG>-V</STRONG> reports the version of <EM>ncurses</EM> which was used in this program, and
259 <STRONG>-w</STRONG> Resize the window to match the size deduced via <STRONG><A HREF="curs_terminfo.3x.html">setupterm(3x)</A></STRONG>.
260 Normally this has no effect, unless <STRONG>setupterm</STRONG> is not able to
261 detect the window size.
263 The arguments for the <STRONG>-e</STRONG>, <STRONG>-i</STRONG>, and <STRONG>-k</STRONG> options may either be entered as
264 actual characters or by using the "hat" notation, i.e., control-h may
265 be specified as "^H" or "^h".
267 If neither <STRONG>-c</STRONG> or <STRONG>-w</STRONG> is given, both options are assumed.
270 </PRE><H2><a name="h2-ENVIRONMENT">ENVIRONMENT</a></H2><PRE>
271 The <STRONG>tset</STRONG> command uses these environment variables:
274 tells <STRONG>tset</STRONG> whether to initialize <EM>TERM</EM> using <STRONG>sh(1)</STRONG> or <STRONG>csh(1)</STRONG>
277 <EM>TERM</EM> Denotes your terminal type. Each terminal type is distinct,
278 though many are similar.
281 may denote the location of a termcap database. If it is not an
282 absolute pathname, e.g., begins with a "/", <STRONG>tset</STRONG> removes the
283 variable from the environment before looking for the terminal
287 </PRE><H2><a name="h2-FILES">FILES</a></H2><PRE>
289 system port name to terminal type mapping database (BSD versions
292 <EM>/usr/share/terminfo</EM>
293 compiled terminal description database directory
296 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
297 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
298 (POSIX.1-2008) nor X/Open Curses Issue 7 documents <STRONG>tset</STRONG> or <STRONG>reset</STRONG>.
300 The AT&T <STRONG>tput</STRONG> utility (AIX, HP-UX, Solaris) incorporated the terminal-
301 mode manipulation as well as termcap-based features such as resetting
302 tabstops from <STRONG>tset</STRONG> in BSD (4.1c), presumably with the intention of
303 making <STRONG>tset</STRONG> obsolete. However, each of those systems still provides
304 <STRONG>tset</STRONG>. In fact, the commonly-used <STRONG>reset</STRONG> utility is always an alias for
305 <STRONG>tset</STRONG>.
307 The <STRONG>tset</STRONG> utility provides backward compatibility with BSD environments;
308 under most modern Unices, <EM>/etc/inittab</EM> and <STRONG>getty(8)</STRONG> can set <EM>TERM</EM>
309 appropriately for each dial-up line, obviating what was <STRONG>tset</STRONG>'s most
310 important use. This implementation behaves like 4.4BSD <STRONG>tset</STRONG>, with a
311 few exceptions we shall consider now.
313 A few options are different because the <EM>TERMCAP</EM> variable is no longer
314 supported under terminfo-based <EM>ncurses</EM>:
316 <STRONG>o</STRONG> The <STRONG>-S</STRONG> option of BSD <STRONG>tset</STRONG> no longer works; it prints an error
317 message to the standard error and dies.
319 <STRONG>o</STRONG> The <STRONG>-s</STRONG> option only sets <EM>TERM</EM>, not <EM>TERMCAP</EM>.
321 There was an undocumented 4.4BSD feature that invoking <STRONG>tset</STRONG> via a link
322 named "TSET" (or via any other name beginning with an upper-case
323 letter) set the terminal to use upper-case only. This feature has been
326 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
327 4.4BSD. None of them were documented in 4.3BSD and all are of limited
328 utility at best. The <STRONG>-a</STRONG>, <STRONG>-d</STRONG>, and <STRONG>-p</STRONG> options are similarly not
329 documented or useful, but were retained as they appear to be in
330 widespread use. It is strongly recommended that any usage of these
331 three options be changed to use the <STRONG>-m</STRONG> option instead. The <STRONG>-a</STRONG>, <STRONG>-d</STRONG>, and
332 <STRONG>-p</STRONG> options are therefore omitted from the usage summary above.
334 Very old systems, e.g., 3BSD, used a different terminal driver which
335 was replaced in 4BSD in the early 1980s. To accommodate these older
336 systems, the 4BSD <STRONG>tset</STRONG> provided a <STRONG>-n</STRONG> option to specify that the new
337 terminal driver should be used. This implementation does not provide
340 It is still permissible to specify the <STRONG>-e</STRONG>, <STRONG>-i</STRONG>, and <STRONG>-k</STRONG> options without
341 arguments, although it is strongly recommended that such usage be fixed
342 to explicitly specify the character.
344 As of 4.4BSD, executing <STRONG>tset</STRONG> as <STRONG>reset</STRONG> no longer implies the <STRONG>-Q</STRONG> option.
345 Also, the interaction between the - option and the <EM>terminal</EM> argument in
346 some historic implementations of <STRONG>tset</STRONG> has been removed.
348 The <STRONG>-c</STRONG> and <STRONG>-w</STRONG> options are not found in earlier implementations.
349 However, a different window size-change feature was provided in 4.4BSD.
351 <STRONG>o</STRONG> In 4.4BSD, <STRONG>tset</STRONG> uses the window size from the termcap description
352 to set the window size if <STRONG>tset</STRONG> is not able to obtain the window
353 size from the operating system.
355 <STRONG>o</STRONG> In <EM>ncurses</EM>, <STRONG>tset</STRONG> obtains the window size using <STRONG><A HREF="curs_terminfo.3x.html">setupterm(3x)</A></STRONG>, which
356 may be from the operating system, the <EM>LINES</EM> and <EM>COLUMNS</EM> environment
357 variables or the terminal description.
359 Obtaining the window size from a terminal's type description is common
360 to both implementations, but considered obsolescent. Its only
361 practical use is for hardware terminals. Generally, the window size
362 will remain uninitialized only if there were a problem obtaining the
363 value from the operating system (and <STRONG>setupterm</STRONG> would still fail). The
364 <EM>LINES</EM> and <EM>COLUMNS</EM> environment variables may thus be useful for working
365 around window-size problems, but have the drawback that if the window
366 is resized, their values must be recomputed and reassigned. The
367 <STRONG>resize(1)</STRONG> program distributed with <STRONG>xterm(1)</STRONG> assists this activity.
370 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
371 A <STRONG>reset</STRONG> command written by Kurt Shoens appeared in 1BSD (March 1978).
372 It set the <EM>erase</EM> and <EM>kill</EM> characters to <STRONG>^H</STRONG> (backspace) and <STRONG>@</STRONG>
373 respectively. Mark Horton improved this <STRONG>reset</STRONG> in 3BSD (October 1979),
374 adding <EM>intr</EM>, <EM>quit</EM>, <EM>start</EM>/<EM>stop</EM>, and <EM>eof</EM> characters as well as changing
375 the program to avoid modifying any user settings. That version of
376 <STRONG>reset</STRONG> did not use <EM>termcap</EM>.
378 Eric Allman wrote a distinct <STRONG>tset</STRONG> command for 1BSD, using a forerunner
379 of <EM>termcap</EM> called <EM>ttycap</EM>. Allman's comments in the source code
380 indicate that he began work in October 1977, continuing development
381 over the next few years. By late 1979, it had migrated to <EM>termcap</EM> and
382 handled the <EM>TERMCAP</EM> variable. Later comments indicate that <STRONG>tset</STRONG> was
383 modified in September 1980 to use logic copied from the 3BSD "reset"
384 program when it was invoked as <STRONG>reset</STRONG>. This version appeared in
385 4.1cBSD, late in 1982. Other developers such as Keith Bostic and Jim
386 Bloom continued to modify <STRONG>tset</STRONG> until 4.4BSD was released in 1993.
388 The <EM>ncurses</EM> implementation was lightly adapted from the 4.4BSD sources
389 to use the <EM>terminfo</EM> API by Eric S. Raymond <esr@snark.thyrsus.com>.
392 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
393 <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>,
394 <STRONG>ttys(5)</STRONG>, <STRONG>environ(7)</STRONG>
398 ncurses 6.5 2024-06-08 <STRONG><A HREF="tset.1.html">tset(1)</A></STRONG>
402 <li><a href="#h2-NAME">NAME</a></li>
403 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
404 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
406 <li><a href="#h3-tset----initialization">tset -- initialization</a></li>
407 <li><a href="#h3-reset----reinitialization">reset -- reinitialization</a></li>
408 <li><a href="#h3-Setting-the-Environment">Setting the Environment</a></li>
409 <li><a href="#h3-Terminal-Type-Mapping">Terminal Type Mapping</a></li>
412 <li><a href="#h2-OPTIONS">OPTIONS</a></li>
413 <li><a href="#h2-ENVIRONMENT">ENVIRONMENT</a></li>
414 <li><a href="#h2-FILES">FILES</a></li>
415 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
416 <li><a href="#h2-HISTORY">HISTORY</a></li>
417 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>