1tset(1)                     General Commands Manual                    tset(1)
2
3
4

NAME

6       tset, reset - terminal initialization
7

SYNOPSIS

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

DESCRIPTION

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 re‐
28       members 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(1) does this  job  by  setting
40       TERM 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 op‐
45       tion 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 en‐
49       tered 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

OPTIONS

104       The options are as follows:
105
106       -c   Set control characters and modes.
107
108       -e ch
109            Set the erase character to ch.
110
111       -I   Do not send the terminal or tab initialization strings to the ter‐
112            minal.
113
114       -i ch
115            Set the interrupt character to ch.
116
117       -k ch
118            Set the line kill character to ch.
119
120       -m mapping
121            Specify a mapping from a port type to a terminal.  See the section
122            TERMINAL TYPE MAPPING for more information.
123
124       -Q   Do  not  display any values for the erase, interrupt and line kill
125            characters.  Normally tset displays the values for control charac‐
126            ters which differ from the system's default values.
127
128       -q   The  terminal  type  is  displayed to the standard output, and the
129            terminal is not initialized in any way.  The option “-” by  itself
130            is equivalent but archaic.
131
132       -r   Print the terminal type to the standard error output.
133
134       -s   Print the sequence of shell commands to initialize the environment
135            variable TERM to the standard output.  See the section SETTING THE
136            ENVIRONMENT for details.
137
138       -V   reports the version of ncurses which was used in this program, and
139            exits.
140
141       -w   Resize the window to match the  size  deduced  via  setupterm(3X).
142            Normally  this  has no effect, unless setupterm is not able to de‐
143            tect the window size.
144
145       The arguments for the -e, -i, and -k options may either be  entered  as
146       actual  characters  or by using the “hat” notation, i.e., control-h may
147       be specified as “^H” or “^h”.
148
149       If neither -c or -w is given, both options are assumed.
150

SETTING THE ENVIRONMENT

152       It is often desirable to enter the terminal type and information  about
153       the terminal's capabilities into the shell's environment.  This is done
154       using the -s option.
155
156       When the -s option is specified, the commands to enter the  information
157       into  the  shell's  environment are written to the standard output.  If
158       the SHELL environmental variable ends in “csh”, the  commands  are  for
159       csh, otherwise, they are for sh(1).  Note, the csh commands set and un‐
160       set the shell variable noglob, leaving it unset.  The following line in
161       the .login or .profile files will initialize the environment correctly:
162
163           eval `tset -s options ... `
164

TERMINAL TYPE MAPPING

166       When the terminal is not hardwired into the system (or the current sys‐
167       tem information is  incorrect)  the  terminal  type  derived  from  the
168       /etc/ttys  file  or  the TERM environmental variable is often something
169       generic like network, dialup, or unknown.   When  tset  is  used  in  a
170       startup  script  it is often desirable to provide information about the
171       type of terminal used on such ports.
172
173       The -m options maps from some set of conditions  to  a  terminal  type,
174       that is, to tell tset “If I'm on this port at a particular speed, guess
175       that I'm on that kind of terminal”.
176
177       The argument to the -m option consists of an optional port type, an op‐
178       tional operator, an optional baud rate specification, an optional colon
179       (“:”) character and a terminal type.  The port type is a string (delim‐
180       ited  by either the operator or the colon character).  The operator may
181       be any combination of “>”, “<”, “@”, and “!”; “>” means  greater  than,
182       “<”  means  less  than, “@” means equal to and “!” inverts the sense of
183       the test.  The baud rate is specified as a number and is compared  with
184       the  speed  of  the  standard error output (which should be the control
185       terminal).  The terminal type is a string.
186
187       If the terminal type is not specified on the command line, the -m  map‐
188       pings are applied to the terminal type.  If the port type and baud rate
189       match the mapping, the terminal type specified in the mapping  replaces
190       the current type.  If more than one mapping is specified, the first ap‐
191       plicable mapping is used.
192
193       For example, consider the following  mapping:  dialup>9600:vt100.   The
194       port type is dialup , the operator is >, the baud rate specification is
195       9600, and the terminal type is vt100.  The result of this mapping is to
196       specify  that  if  the  terminal  type  is dialup, and the baud rate is
197       greater than 9600 baud, a terminal type of vt100 will be used.
198
199       If no baud rate is specified, the terminal type  will  match  any  baud
200       rate.   If  no port type is specified, the terminal type will match any
201       port type.  For example, -m dialup:vt100 -m :?xterm will cause any  di‐
202       alup  port,  regardless of baud rate, to match the terminal type vt100,
203       and any non-dialup port type to match the terminal type ?xterm.   Note,
204       because of the leading question mark, the user will be queried on a de‐
205       fault port as to whether they are actually using an xterm terminal.
206
207       No whitespace characters are  permitted  in  the  -m  option  argument.
208       Also,  to avoid problems with meta-characters, it is suggested that the
209       entire -m option argument be placed within single quote characters, and
210       that  csh  users insert a backslash character (“\”) before any exclama‐
211       tion marks (“!”).
212

HISTORY

214       A reset command appeared in 1BSD (March 1978), written by Kurt  Shoens.
215       This  program set the erase and kill characters to ^H (backspace) and @
216       respectively.  Mark Horton improved that in 3BSD (October 1979), adding
217       intr,  quit, start/stop and eof characters as well as changing the pro‐
218       gram to avoid modifying any user settings.  That version of  reset  did
219       not use the termcap database.
220
221       A  separate tset command was provided in 1BSD by Eric Allman, using the
222       termcap database.  Allman's comments in the source code  indicate  that
223       he began work in October 1977, continuing development over the next few
224       years.
225
226       According to comments in the source code, the tset program was modified
227       in  September  1980,  to use logic copied from the 3BSD “reset” when it
228       was invoked as reset.  This version appeared in 4.1cBSD, late in 1982.
229
230       Other developers (e.g., Keith Bostic and Jim Bloom) continued to modify
231       tset until 4.4BSD was released in 1993.
232
233       The  ncurses implementation was lightly adapted from the 4.4BSD sources
234       for a terminfo environment by Eric S. Raymond <esr@snark.thyrsus.com>.
235

COMPATIBILITY

237       Neither IEEE Std 1003.1/The Open  Group  Base  Specifications  Issue  7
238       (POSIX.1-2008) nor X/Open Curses Issue 7 documents tset or reset.
239
240       The  AT&T  tput utility (AIX, HPUX, Solaris) incorporated the terminal-
241       mode manipulation as well as termcap-based features such  as  resetting
242       tabstops from tset in BSD (4.1c), presumably with the intention of mak‐
243       ing tset obsolete.  However, each of those systems still provides tset.
244       In fact, the commonly-used reset utility is always an alias for tset.
245
246       The  tset utility provides for backward-compatibility with BSD environ‐
247       ments (under most modern UNIXes, /etc/inittab and getty(1) can set TERM
248       appropriately for each dial-up line; this obviates what was tset's most
249       important use).  This implementation behaves like 4.4BSD tset,  with  a
250       few exceptions specified here.
251
252       A  few  options are different because the TERMCAP variable is no longer
253       supported under terminfo-based ncurses:
254
255       •   The -S option of BSD tset no longer works; it prints an error  mes‐
256           sage to the standard error and dies.
257
258       •   The -s option only sets TERM, not TERMCAP.
259
260       There  was an undocumented 4.4BSD feature that invoking tset via a link
261       named “TSET” (or via any other name beginning with an  upper-case  let‐
262       ter)  set  the  terminal to use upper-case only.  This feature has been
263       omitted.
264
265       The -A, -E, -h, -u and -v options were deleted from the tset utility in
266       4.4BSD.   None of them were documented in 4.3BSD and all are of limited
267       utility at best.  The -a, -d, and -p options are  similarly  not  docu‐
268       mented  or useful, but were retained as they appear to be in widespread
269       use.  It is strongly recommended that any usage of these three  options
270       be  changed  to  use the -m option instead.  The -a, -d, and -p options
271       are therefore omitted from the usage summary above.
272
273       Very old systems, e.g., 3BSD, used a different  terminal  driver  which
274       was  replaced  in  4BSD in the early 1980s.  To accommodate these older
275       systems, the 4BSD tset provided a -n option to  specify  that  the  new
276       terminal  driver  should be used.  This implementation does not provide
277       that choice.
278
279       It is still permissible to specify the -e, -i, and -k  options  without
280       arguments, although it is strongly recommended that such usage be fixed
281       to explicitly specify the character.
282
283       As of 4.4BSD, executing tset as reset no longer implies the -Q  option.
284       Also, the interaction between the - option and the terminal argument in
285       some historic implementations of tset has been removed.
286
287       The -c and -w options are not found in earlier  implementations.   How‐
288       ever, a different window size-change feature was provided in 4.4BSD.
289
290       •   In  4.4BSD,  tset uses the window size from the termcap description
291           to set the window size if tset is not able  to  obtain  the  window
292           size from the operating system.
293
294       •   In ncurses, tset obtains the window size using setupterm, which may
295           be from the operating system, the  LINES  and  COLUMNS  environment
296           variables or the terminal description.
297
298       Obtaining  the  window  size from the terminal description is common to
299       both implementations, but considered obsolescent.  Its  only  practical
300       use is for hardware terminals.  Generally speaking, a window size would
301       be unset only if there were some problem obtaining the value  from  the
302       operating  system  (and  setupterm would still fail).  For that reason,
303       the LINES and COLUMNS environment variables may be useful  for  working
304       around  window-size problems.  Those have the drawback that if the win‐
305       dow is resized, those variables must be recomputed and reassigned.   To
306       do this more easily, use the resize(1) program.
307

ENVIRONMENT

309       The tset command uses these environment variables:
310
311       SHELL
312            tells  tset  whether to initialize TERM using sh(1) or csh(1) syn‐
313            tax.
314
315       TERM Denotes your terminal  type.   Each  terminal  type  is  distinct,
316            though many are similar.
317
318       TERMCAP
319            may  denote  the  location of a termcap database.  If it is not an
320            absolute pathname, e.g., begins with a “/”, tset removes the vari‐
321            able from the environment before looking for the terminal descrip‐
322            tion.
323

FILES

325       /etc/ttys
326            system port name to terminal type mapping database  (BSD  versions
327            only).
328
329       /usr/share/terminfo
330            terminal capability database
331

SEE ALSO

333       csh(1),   sh(1),   stty(1),   curs_terminfo(3X),  tty(4),  terminfo(5),
334       ttys(5), environ(7)
335
336       This describes ncurses version 6.4 (patch 20230520).
337
338
339
340                                                                       tset(1)
Impressum