1tset(1) General Commands Manual tset(1)
2
3
4
6 tset, reset - terminal initialization
7
9 tset [-IQVcqrsw] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]
10 reset [-IQVcqrsw] [-] [-e ch] [-i ch] [-k ch] [-m mapping] [terminal]
11
13 tset - initialization
14 This program initializes terminals.
15
16 First, tset retrieves the current terminal mode settings for your ter‐
17 minal. It does this by successively testing
18
19 · the standard error,
20
21 · standard output,
22
23 · standard input and
24
25 · ultimately “/dev/tty”
26
27 to obtain terminal settings. Having retrieved these settings, tset
28 remembers which file descriptor to use when updating settings.
29
30 Next, tset determines the type of terminal that you are using. This
31 determination is done as follows, using the first terminal type found.
32
33 1. The terminal argument specified on the command line.
34
35 2. The value of the TERM environmental variable.
36
37 3. (BSD systems only.) The terminal type associated with the standard
38 error output device in the /etc/ttys file. (On System-V-like UNIXes
39 and systems using that convention, getty does this job by setting TERM
40 according to the type passed to it by /etc/inittab.)
41
42 4. The default terminal type, “unknown”.
43
44 If the terminal type was not specified on the command-line, the -m
45 option mappings are then applied (see the section TERMINAL TYPE MAPPING
46 for more information). Then, if the terminal type begins with a ques‐
47 tion mark (“?”), the user is prompted for confirmation of the terminal
48 type. An empty response confirms the type, or, another type can be
49 entered to specify a new type. Once the terminal type has been deter‐
50 mined, the terminal description for the terminal is retrieved. If no
51 terminal description is found for the type, the user is prompted for
52 another terminal type.
53
54 Once the terminal description is retrieved,
55
56 · if the “-w” option is enabled, tset may update the terminal's win‐
57 dow size.
58
59 If the window size cannot be obtained from the operating system,
60 but the terminal description (or environment, e.g., LINES and COL‐
61 UMNS variables specify this), use this to set the operating sys‐
62 tem's notion of the window size.
63
64 · if the “-c” option is enabled, the backspace, interrupt and line
65 kill characters (among many other things) are set
66
67 · unless the “-I” option is enabled, the terminal and tab initializa‐
68 tion strings are sent to the standard error output, and tset waits
69 one second (in case a hardware reset was issued).
70
71 · Finally, if the erase, interrupt and line kill characters have
72 changed, or are not set to their default values, their values are
73 displayed to the standard error output.
74
75 reset - reinitialization
76 When invoked as reset, tset sets the terminal modes to “sane” values:
77
78 · sets cooked and echo modes,
79
80 · turns off cbreak and raw modes,
81
82 · turns on newline translation and
83
84 · resets any unset special characters to their default values
85
86 before doing the terminal initialization described above. Also, rather
87 than using the terminal initialization strings, it uses the terminal
88 reset strings.
89
90 The reset command is useful after a program dies leaving a terminal in
91 an abnormal state:
92
93 · you may have to type
94
95 <LF>reset<LF>
96
97 (the line-feed character is normally control-J) to get the terminal
98 to work, as carriage-return may no longer work in the abnormal
99 state.
100
101 · Also, the terminal will often not echo the command.
102
104 The options are as follows:
105
106 -c Set control characters and modes.
107
108 -e Set the erase character to ch.
109
110 -I Do not send the terminal or tab initialization strings to the ter‐
111 minal.
112
113 -i Set the interrupt character to ch.
114
115 -k Set the line kill character to ch.
116
117 -m Specify a mapping from a port type to a terminal. See the section
118 TERMINAL TYPE MAPPING for more information.
119
120 -Q Do not display any values for the erase, interrupt and line kill
121 characters. Normally tset displays the values for control charac‐
122 ters which differ from the system's default values.
123
124 -q The terminal type is displayed to the standard output, and the
125 terminal is not initialized in any way. The option “-” by itself
126 is equivalent but archaic.
127
128 -r Print the terminal type to the standard error output.
129
130 -s Print the sequence of shell commands to initialize the environment
131 variable TERM to the standard output. See the section SETTING THE
132 ENVIRONMENT for details.
133
134 -V reports the version of ncurses which was used in this program, and
135 exits.
136
137 -w Resize the window to match the size deduced via setupterm(3X).
138 Normally this has no effect, unless setupterm is not able to
139 detect the window size.
140
141 The arguments for the -e, -i, and -k options may either be entered as
142 actual characters or by using the “hat” notation, i.e., control-h may
143 be specified as “^H” or “^h”.
144
145 If neither -c or -w is given, both options are assumed.
146
148 It is often desirable to enter the terminal type and information about
149 the terminal's capabilities into the shell's environment. This is done
150 using the -s option.
151
152 When the -s option is specified, the commands to enter the information
153 into the shell's environment are written to the standard output. If
154 the SHELL environmental variable ends in “csh”, the commands are for
155 csh, otherwise, they are for sh. Note, the csh commands set and unset
156 the shell variable noglob, leaving it unset. The following line in the
157 .login or .profile files will initialize the environment correctly:
158
159 eval `tset -s options ... `
160
162 When the terminal is not hardwired into the system (or the current sys‐
163 tem information is incorrect) the terminal type derived from the
164 /etc/ttys file or the TERM environmental variable is often something
165 generic like network, dialup, or unknown. When tset is used in a
166 startup script it is often desirable to provide information about the
167 type of terminal used on such ports.
168
169 The -m options maps from some set of conditions to a terminal type,
170 that is, to tell tset “If I'm on this port at a particular speed, guess
171 that I'm on that kind of terminal”.
172
173 The argument to the -m option consists of an optional port type, an
174 optional operator, an optional baud rate specification, an optional
175 colon (“:”) character and a terminal type. The port type is a string
176 (delimited by either the operator or the colon character). The opera‐
177 tor may be any combination of “>”, “<”, “@”, and “!”; “>” means greater
178 than, “<” means less than, “@” means equal to and “!” inverts the sense
179 of the test. The baud rate is specified as a number and is compared
180 with the speed of the standard error output (which should be the con‐
181 trol terminal). The terminal type is a string.
182
183 If the terminal type is not specified on the command line, the -m map‐
184 pings are applied to the terminal type. If the port type and baud rate
185 match the mapping, the terminal type specified in the mapping replaces
186 the current type. If more than one mapping is specified, the first
187 applicable mapping is used.
188
189 For example, consider the following mapping: dialup>9600:vt100. The
190 port type is dialup , the operator is >, the baud rate specification is
191 9600, and the terminal type is vt100. The result of this mapping is to
192 specify that if the terminal type is dialup, and the baud rate is
193 greater than 9600 baud, a terminal type of vt100 will be used.
194
195 If no baud rate is specified, the terminal type will match any baud
196 rate. If no port type is specified, the terminal type will match any
197 port type. For example, -m dialup:vt100 -m :?xterm will cause any
198 dialup port, regardless of baud rate, to match the terminal type vt100,
199 and any non-dialup port type to match the terminal type ?xterm. Note,
200 because of the leading question mark, the user will be queried on a
201 default port as to whether they are actually using an xterm terminal.
202
203 No whitespace characters are permitted in the -m option argument.
204 Also, to avoid problems with meta-characters, it is suggested that the
205 entire -m option argument be placed within single quote characters, and
206 that csh users insert a backslash character (“\”) before any exclama‐
207 tion marks (“!”).
208
210 A reset command appeared in 2BSD (April 1979), written by Kurt Shoens.
211 This program set the erase and kill characters to ^H (backspace) and @
212 respectively. Mark Horton improved that in 3BSD (October 1979), adding
213 intr, quit, start/stop and eof characters as well as changing the pro‐
214 gram to avoid modifying any user settings.
215
216 Later in 4.1BSD (December 1980), Mark Horton added a call to the tset
217 program using the -I and -Q options, i.e., using that to improve the
218 terminal modes. With those options, that version of reset did not use
219 the termcap database.
220
221 A separate tset command was provided in 2BSD by Eric Allman. While the
222 oldest published source (from 1979) provides both tset and reset, All‐
223 man's comments in the 2BSD source code indicate that he began work in
224 October 1977, continuing development over the next few years.
225
226 In September 1980, Eric Allman modified tset, adding the code from the
227 existing “reset” feature when tset was invoked as reset. Rather than
228 simply copying the existing program, in this merged version, tset used
229 the termcap database to do additional (re)initialization of the termi‐
230 nal. This version appeared in 4.1cBSD, late in 1982.
231
232 Other developers (e.g., Keith Bostic and Jim Bloom) continued to modify
233 tset until 4.4BSD was released in 1993.
234
235 The ncurses implementation was lightly adapted from the 4.4BSD sources
236 for a terminfo environment by Eric S. Raymond <esr@snark.thyrsus.com>.
237
239 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
240 (POSIX.1-2008) nor X/Open Curses Issue 7 documents tset or reset.
241
242 The AT&T tput utility (AIX, HPUX, Solaris) incorporated the terminal-
243 mode manipulation as well as termcap-based features such as resetting
244 tabstops from tset in BSD (4.1c), presumably with the intention of mak‐
245 ing tset obsolete. However, each of those systems still provides tset.
246 In fact, the commonly-used reset utility is always an alias for tset.
247
248 The tset utility provides for backward-compatibility with BSD environ‐
249 ments (under most modern UNIXes, /etc/inittab and getty(1) can set TERM
250 appropriately for each dial-up line; this obviates what was tset's most
251 important use). This implementation behaves like 4.4BSD tset, with a
252 few exceptions specified here.
253
254 A few options are different because the TERMCAP variable is no longer
255 supported under terminfo-based ncurses:
256
257 · The -S option of BSD tset no longer works; it prints an error mes‐
258 sage to the standard error and dies.
259
260 · The -s option only sets TERM, not TERMCAP.
261
262 There was an undocumented 4.4BSD feature that invoking tset via a link
263 named “TSET” (or via any other name beginning with an upper-case let‐
264 ter) set the terminal to use upper-case only. This feature has been
265 omitted.
266
267 The -A, -E, -h, -u and -v options were deleted from the tset utility in
268 4.4BSD. None of them were documented in 4.3BSD and all are of limited
269 utility at best. The -a, -d, and -p options are similarly not docu‐
270 mented or useful, but were retained as they appear to be in widespread
271 use. It is strongly recommended that any usage of these three options
272 be changed to use the -m option instead. The -a, -d, and -p options
273 are therefore omitted from the usage summary above.
274
275 Very old systems, e.g., 3BSD, used a different terminal driver which
276 was replaced in 4BSD in the early 1980s. To accommodate these older
277 systems, the 4BSD tset provided a -n option to specify that the new
278 terminal driver should be used. This implementation does not provide
279 that choice.
280
281 It is still permissible to specify the -e, -i, and -k options without
282 arguments, although it is strongly recommended that such usage be fixed
283 to explicitly specify the character.
284
285 As of 4.4BSD, executing tset as reset no longer implies the -Q option.
286 Also, the interaction between the - option and the terminal argument in
287 some historic implementations of tset has been removed.
288
289 The -c and -w options are not found in earlier implementations. How‐
290 ever, a different window size-change feature was provided in 4.4BSD.
291
292 · In 4.4BSD, tset uses the window size from the termcap description
293 to set the window size if tset is not able to obtain the window
294 size from the operating system.
295
296 · In ncurses, tset obtains the window size using setupterm, which may
297 be from the operating system, the LINES and COLUMNS environment
298 variables or the terminal description.
299
300 Obtaining the window size from the terminal description is common to
301 both implementations, but considered obsolescent. Its only practical
302 use is for hardware terminals. Generally speaking, a window size would
303 be unset only if there were some problem obtaining the value from the
304 operating system (and setupterm would still fail). For that reason,
305 the LINES and COLUMNS environment variables may be useful for working
306 around window-size problems. Those have the drawback that if the win‐
307 dow is resized, those variables must be recomputed and reassigned. To
308 do this more easily, use the resize(1) program.
309
311 The tset command uses these environment variables:
312
313 SHELL
314 tells tset whether to initialize TERM using sh or csh syntax.
315
316 TERM Denotes your terminal type. Each terminal type is distinct,
317 though many are similar.
318
319 TERMCAP
320 may denote the location of a termcap database. If it is not an
321 absolute pathname, e.g., begins with a “/”, tset removes the vari‐
322 able from the environment before looking for the terminal descrip‐
323 tion.
324
326 /etc/ttys
327 system port name to terminal type mapping database (BSD versions
328 only).
329
330 /usr/share/terminfo
331 terminal capability database
332
334 csh(1), sh(1), stty(1), curs_terminfo(3X), tty(4), terminfo(5),
335 ttys(5), environ(7)
336
337 This describes ncurses version 6.1 (patch 20180923).
338
339
340
341 tset(1)