2 ****************************************************************************
3 * Copyright 2018-2020,2021 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.56 2021/06/17 21:26:02 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</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
39 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
42 <H1 class="no-header">@TSET@ 1</H1>
44 <B><A HREF="tset.1.html">tset(1)</A></B> General Commands Manual <B><A HREF="tset.1.html">tset(1)</A></B>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <B>tset</B>, <B>reset</B> - terminal initialization
53 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
54 <B>tset</B> [<B>-IQVcqrsw</B>] [<B>-</B>] [<B>-e</B> <I>ch</I>] [<B>-i</B> <I>ch</I>] [<B>-k</B> <I>ch</I>] [<B>-m</B> <I>mapping</I>] [<I>terminal</I>]
55 <B>reset</B> [<B>-IQVcqrsw</B>] [<B>-</B>] [<B>-e</B> <I>ch</I>] [<B>-i</B> <I>ch</I>] [<B>-k</B> <I>ch</I>] [<B>-m</B> <I>mapping</I>] [<I>terminal</I>]
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, <B>tset</B> retrieves the current terminal mode settings for your
64 terminal. It does this by successively testing
66 <B>o</B> the standard error,
68 <B>o</B> standard output,
70 <B>o</B> standard input and
72 <B>o</B> ultimately "/dev/tty"
74 to obtain terminal settings. Having retrieved these settings, <B>tset</B>
75 remembers which file descriptor to use when updating settings.
77 Next, <B>tset</B> 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 <B>terminal</B> argument specified on the command line.
82 2. The value of the <B>TERM</B> environmental variable.
84 3. (BSD systems only.) The terminal type associated with the standard
85 error output device in the <I>/etc/ttys</I> file. (On System-V-like UNIXes
86 and systems using that convention, <I>getty</I> does this job by setting <B>TERM</B>
87 according to the type passed to it by <I>/etc/inittab</I>.)
89 4. The default terminal type, "unknown".
91 If the terminal type was not specified on the command-line, the <B>-m</B>
92 option mappings are then applied (see the section <B>TERMINAL</B> <B>TYPE</B> <B>MAPPING</B>
93 for more information). Then, if the terminal type begins with a
94 question mark ("?"), the user is prompted for confirmation of the
95 terminal type. An empty response confirms the type, or, another type
96 can be entered to specify a new type. Once the terminal type has been
97 determined, the terminal description for the terminal is retrieved. If
98 no terminal description is found for the type, the user is prompted for
99 another terminal type.
101 Once the terminal description is retrieved,
103 <B>o</B> if the "<B>-w</B>" option is enabled, <B>tset</B> may update the terminal's
106 If the window size cannot be obtained from the operating system,
107 but the terminal description (or environment, e.g., <B>LINES</B> and
108 <B>COLUMNS</B> variables specify this), use this to set the operating
109 system's notion of the window size.
111 <B>o</B> if the "<B>-c</B>" option is enabled, the backspace, interrupt and line
112 kill characters (among many other things) are set
114 <B>o</B> unless the "<B>-I</B>" option is enabled, the terminal and tab
115 <I>initialization</I> strings are sent to the standard error output, and
116 <B>tset</B> waits one second (in case a hardware reset was issued).
118 <B>o</B> Finally, if the erase, interrupt and line kill characters have
119 changed, or are not set to their default values, their values are
120 displayed to the standard error output.
123 </PRE><H3><a name="h3-reset---reinitialization">reset - reinitialization</a></H3><PRE>
124 When invoked as <B>reset</B>, <B>tset</B> sets the terminal modes to "sane" values:
126 <B>o</B> sets cooked and echo modes,
128 <B>o</B> turns off cbreak and raw modes,
130 <B>o</B> turns on newline translation and
132 <B>o</B> resets any unset special characters to their default values
134 before doing the terminal initialization described above. Also, rather
135 than using the terminal <I>initialization</I> strings, it uses the terminal
136 <I>reset</I> strings.
138 The <B>reset</B> command is useful after a program dies leaving a terminal in
141 <B>o</B> you may have to type
143 <I><LF></I><B>reset</B><I><LF></I>
145 (the line-feed character is normally control-J) to get the terminal
146 to work, as carriage-return may no longer work in the abnormal
149 <B>o</B> Also, the terminal will often not echo the command.
152 </PRE><H2><a name="h2-OPTIONS">OPTIONS</a></H2><PRE>
153 The options are as follows:
155 <B>-c</B> Set control characters and modes.
157 <B>-e</B> Set the erase character to <I>ch</I>.
159 <B>-I</B> Do not send the terminal or tab initialization strings to the
162 <B>-i</B> Set the interrupt character to <I>ch</I>.
164 <B>-k</B> Set the line kill character to <I>ch</I>.
166 <B>-m</B> Specify a mapping from a port type to a terminal. See the section
167 <B>TERMINAL</B> <B>TYPE</B> <B>MAPPING</B> for more information.
169 <B>-Q</B> Do not display any values for the erase, interrupt and line kill
170 characters. Normally <B>tset</B> displays the values for control
171 characters which differ from the system's default values.
173 <B>-q</B> The terminal type is displayed to the standard output, and the
174 terminal is not initialized in any way. The option "-" by itself
175 is equivalent but archaic.
177 <B>-r</B> Print the terminal type to the standard error output.
179 <B>-s</B> Print the sequence of shell commands to initialize the environment
180 variable <B>TERM</B> to the standard output. See the section <B>SETTING</B> <B>THE</B>
181 <B>ENVIRONMENT</B> for details.
183 <B>-V</B> reports the version of ncurses which was used in this program, and
186 <B>-w</B> Resize the window to match the size deduced via <B><A HREF="curs_terminfo.3X.html">setupterm(3X)</A></B>.
187 Normally this has no effect, unless <B>setupterm</B> is not able to
188 detect the window size.
190 The arguments for the <B>-e</B>, <B>-i</B>, and <B>-k</B> options may either be entered as
191 actual characters or by using the "hat" notation, i.e., control-h may
192 be specified as "^H" or "^h".
194 If neither <B>-c</B> or <B>-w</B> is given, both options are assumed.
197 </PRE><H2><a name="h2-SETTING-THE-ENVIRONMENT">SETTING THE ENVIRONMENT</a></H2><PRE>
198 It is often desirable to enter the terminal type and information about
199 the terminal's capabilities into the shell's environment. This is done
200 using the <B>-s</B> option.
202 When the <B>-s</B> option is specified, the commands to enter the information
203 into the shell's environment are written to the standard output. If
204 the <B>SHELL</B> environmental variable ends in "csh", the commands are for
205 <B>csh</B>, otherwise, they are for <B>sh</B>. Note, the <B>csh</B> commands set and unset
206 the shell variable <B>noglob</B>, leaving it unset. The following line in the
207 <B>.login</B> or <B>.profile</B> files will initialize the environment correctly:
209 eval `tset -s options ... `
212 </PRE><H2><a name="h2-TERMINAL-TYPE-MAPPING">TERMINAL TYPE MAPPING</a></H2><PRE>
213 When the terminal is not hardwired into the system (or the current
214 system information is incorrect) the terminal type derived from the
215 <I>/etc/ttys</I> file or the <B>TERM</B> environmental variable is often something
216 generic like <B>network</B>, <B>dialup</B>, or <B>unknown</B>. When <B>tset</B> is used in a
217 startup script it is often desirable to provide information about the
218 type of terminal used on such ports.
220 The <B>-m</B> options maps from some set of conditions to a terminal type,
221 that is, to tell <B>tset</B> "If I'm on this port at a particular speed, guess
222 that I'm on that kind of terminal".
224 The argument to the <B>-m</B> option consists of an optional port type, an
225 optional operator, an optional baud rate specification, an optional
226 colon (":") character and a terminal type. The port type is a string
227 (delimited by either the operator or the colon character). The
228 operator may be any combination of ">", "<", "@", and "!"; ">" means
229 greater than, "<" means less than, "@" means equal to and "!" inverts
230 the sense of the test. The baud rate is specified as a number and is
231 compared with the speed of the standard error output (which should be
232 the control terminal). The terminal type is a string.
234 If the terminal type is not specified on the command line, the <B>-m</B>
235 mappings are applied to the terminal type. If the port type and baud
236 rate match the mapping, the terminal type specified in the mapping
237 replaces the current type. If more than one mapping is specified, the
238 first applicable mapping is used.
240 For example, consider the following mapping: <B>dialup>9600:vt100</B>. The
241 port type is dialup , the operator is >, the baud rate specification is
242 9600, and the terminal type is vt100. The result of this mapping is to
243 specify that if the terminal type is <B>dialup</B>, and the baud rate is
244 greater than 9600 baud, a terminal type of <B>vt100</B> will be used.
246 If no baud rate is specified, the terminal type will match any baud
247 rate. If no port type is specified, the terminal type will match any
248 port type. For example, <B>-m</B> <B>dialup:vt100</B> <B>-m</B> <B>:?xterm</B> will cause any
249 dialup port, regardless of baud rate, to match the terminal type vt100,
250 and any non-dialup port type to match the terminal type ?xterm. Note,
251 because of the leading question mark, the user will be queried on a
252 default port as to whether they are actually using an xterm terminal.
254 No whitespace characters are permitted in the <B>-m</B> option argument.
255 Also, to avoid problems with meta-characters, it is suggested that the
256 entire <B>-m</B> option argument be placed within single quote characters, and
257 that <B>csh</B> users insert a backslash character ("\") before any
258 exclamation marks ("!").
261 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
262 A <B>reset</B> command appeared in 2BSD (April 1979), written by Kurt Shoens.
263 This program set the <I>erase</I> and <I>kill</I> characters to <B>^H</B> (backspace) and <B>@</B>
264 respectively. Mark Horton improved that in 3BSD (October 1979), adding
265 <I>intr</I>, <I>quit</I>, <I>start</I>/<I>stop</I> and <I>eof</I> characters as well as changing the
266 program to avoid modifying any user settings.
268 Later in 4.1BSD (December 1980), Mark Horton added a call to the <B>tset</B>
269 program using the <B>-I</B> and <B>-Q</B> options, i.e., using that to improve the
270 terminal modes. With those options, that version of <B>reset</B> did not use
271 the termcap database.
273 A separate <B>tset</B> command was provided in 2BSD by Eric Allman. While the
274 oldest published source (from 1979) provides both <B>tset</B> and <B>reset</B>,
275 Allman's comments in the 2BSD source code indicate that he began work
276 in October 1977, continuing development over the next few years.
278 In September 1980, Eric Allman modified <B>tset</B>, adding the code from the
279 existing "reset" feature when <B>tset</B> was invoked as <B>reset</B>. Rather than
280 simply copying the existing program, in this merged version, <B>tset</B> used
281 the termcap database to do additional (re)initialization of the
282 terminal. This version appeared in 4.1cBSD, late in 1982.
284 Other developers (e.g., Keith Bostic and Jim Bloom) continued to modify
285 <B>tset</B> until 4.4BSD was released in 1993.
287 The <B>ncurses</B> 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 <B>tset</B> or <B>reset</B>.
295 The AT&T <B>tput</B> utility (AIX, HPUX, Solaris) incorporated the terminal-
296 mode manipulation as well as termcap-based features such as resetting
297 tabstops from <B>tset</B> in BSD (4.1c), presumably with the intention of
298 making <B>tset</B> obsolete. However, each of those systems still provides
299 <B>tset</B>. In fact, the commonly-used <B>reset</B> utility is always an alias for
302 The <B>tset</B> utility provides for backward-compatibility with BSD
303 environments (under most modern UNIXes, <B>/etc/inittab</B> and <B>getty(1)</B> can
304 set <B>TERM</B> appropriately for each dial-up line; this obviates what was
305 <B>tset</B>'s most important use). This implementation behaves like 4.4BSD
306 <B>tset</B>, with a few exceptions specified here.
308 A few options are different because the <B>TERMCAP</B> variable is no longer
309 supported under terminfo-based <B>ncurses</B>:
311 <B>o</B> The <B>-S</B> option of BSD <B>tset</B> no longer works; it prints an error
312 message to the standard error and dies.
314 <B>o</B> The <B>-s</B> option only sets <B>TERM</B>, not <B>TERMCAP</B>.
316 There was an undocumented 4.4BSD feature that invoking <B>tset</B> 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 <B>-A</B>, <B>-E</B>, <B>-h</B>, <B>-u</B> and <B>-v</B> options were deleted from the <B>tset</B> utility in
322 4.4BSD. None of them were documented in 4.3BSD and all are of limited
323 utility at best. The <B>-a</B>, <B>-d</B>, and <B>-p</B> 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 <B>-m</B> option instead. The <B>-a</B>, <B>-d</B>, and
327 <B>-p</B> 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 <B>tset</B> provided a <B>-n</B> 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 <B>-e</B>, <B>-i</B>, and <B>-k</B> 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 <B>tset</B> as <B>reset</B> no longer implies the <B>-Q</B> option.
340 Also, the interaction between the - option and the <I>terminal</I> argument in
341 some historic implementations of <B>tset</B> has been removed.
343 The <B>-c</B> and <B>-w</B> options are not found in earlier implementations.
344 However, a different window size-change feature was provided in 4.4BSD.
346 <B>o</B> In 4.4BSD, <B>tset</B> uses the window size from the termcap description
347 to set the window size if <B>tset</B> is not able to obtain the window
348 size from the operating system.
350 <B>o</B> In ncurses, <B>tset</B> obtains the window size using <B>setupterm</B>, which may
351 be from the operating system, the <B>LINES</B> and <B>COLUMNS</B> 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 <B>setupterm</B> would still fail). For that reason,
359 the <B>LINES</B> and <B>COLUMNS</B> 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 <B><A HREF="resize.1.html">resize(1)</A></B> program.
365 </PRE><H2><a name="h2-ENVIRONMENT">ENVIRONMENT</a></H2><PRE>
366 The <B>tset</B> command uses these environment variables:
369 tells <B>tset</B> whether to initialize <B>TERM</B> using <B>sh</B> or <B>csh</B> syntax.
371 TERM Denotes your terminal type. Each terminal type is distinct,
372 though many are similar.
375 may denote the location of a termcap database. If it is not an
376 absolute pathname, e.g., begins with a "/", <B>tset</B> removes the
377 variable from the environment before looking for the terminal
381 </PRE><H2><a name="h2-FILES">FILES</a></H2><PRE>
383 system port name to terminal type mapping database (BSD versions
387 terminal capability database
390 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
391 <B>csh(1)</B>, <B>sh(1)</B>, <B>stty(1)</B>, <B><A HREF="curs_terminfo.3X.html">curs_terminfo(3X)</A></B>, <B>tty(4)</B>, <B><A HREF="terminfo.5.html">terminfo(5)</A></B>,
392 <B>ttys(5)</B>, <B>environ(7)</B>
394 This describes <B>ncurses</B> version 6.2 (patch 20210612).
398 <B><A HREF="tset.1.html">tset(1)</A></B>
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>
410 <li><a href="#h2-OPTIONS">OPTIONS</a></li>
411 <li><a href="#h2-SETTING-THE-ENVIRONMENT">SETTING THE ENVIRONMENT</a></li>
412 <li><a href="#h2-TERMINAL-TYPE-MAPPING">TERMINAL TYPE MAPPING</a></li>
413 <li><a href="#h2-HISTORY">HISTORY</a></li>
414 <li><a href="#h2-COMPATIBILITY">COMPATIBILITY</a></li>
415 <li><a href="#h2-ENVIRONMENT">ENVIRONMENT</a></li>
416 <li><a href="#h2-FILES">FILES</a></li>
417 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>