1.\" Copyright (c) 1985, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)tset.1 8.1 (Berkeley) 06/09/93 7.\" 8.Dd 9.Dt TSET 1 10.Os BSD 4 11.Sh NAME 12.Nm tset 13.Nd terminal initialization 14.Sh SYNOPSIS 15.Nm tset 16.Op Fl IQrSs 17.Op Fl 18.Op Fl e Ar ch 19.Op Fl i Ar ch 20.Op Fl k Ar ch 21.Op Fl m Ar mapping 22.Op Ar terminal 23.br 24.Nm reset 25.Op Fl IQrSs 26.Op Fl 27.Op Fl e Ar ch 28.Op Fl i Ar ch 29.Op Fl k Ar ch 30.Op Fl m Ar mapping 31.Op Ar terminal 32.Sh DESCRIPTION 33.Nm Tset 34initializes terminals. 35.Nm Tset 36first determines the type of terminal that you are using. 37This determination is done as follows, using the first terminal type found. 38.sp 39.Bl -bullet -compact -offset indent 40.It 41The 42.Ar terminal 43argument specified on the command line. 44.It 45The value of the 46.Ev TERM 47environmental variable. 48.It 49The terminal type associated with the standard error output device in the 50.Pa /etc/ttys 51file. 52.It 53The default terminal type, ``unknown''. 54.El 55.Pp 56If the terminal type was not specified on the command-line, the 57.Fl m 58option mappings are then applied (see below for more information). 59Then, if the terminal type begins with a question mark (``?''), the user is 60prompted for confirmation of the terminal type. 61An empty response confirms the type, or, another type can be entered to 62specify a new type. 63Once the terminal type has been determined, the termcap entry for the terminal 64is retrieved. 65If no termcap entry is found for the type, the user is prompted for another 66terminal type. 67.Pp 68Once the termcap entry is retrieved, the window size, backspace, interrupt 69and line kill characters (among many other things) are set and the terminal 70and tab initialization strings are sent to the standard error output. 71Finally, if the erase, interrupt and line kill characters have changed, 72or are not set to their default values, their values are displayed to the 73standard error output. 74.Pp 75When invoked as 76.Nm reset , 77.Nm tset 78sets cooked and echo modes, turns off cbreak and raw modes, turns on 79newline translation and resets any unset special characters to their 80default values before doing the terminal initialization described above. 81This is useful after a program dies leaving a terminal in a abnormal state. 82Note, you may have to type 83.Dq Li <LF>reset<LF> 84(the line-feed character is normally control-J) to get the terminal 85to work, as carriage-return may no longer work in the abnormal state. 86Also, the terminal will often not echo the command. 87.Pp 88The options are as follows: 89.Bl -tag -width flag 90.It Fl 91The terminal type is displayed to the standard output, and the terminal is 92not initialized in any way. 93.It Fl e 94Set the erase character to 95.Ar ch . 96.It Fl I 97Do not send the terminal or tab initialization strings to the terminal. 98.It Fl i 99Set the interrupt character to 100.Ar ch . 101.It Fl k 102Set the line kill character to 103.Ar ch . 104.It Fl m 105Specify a mapping from a port type to a terminal. 106See below for more information. 107.It Fl Q 108Don't display any values for the erase, interrupt and line kill characters. 109.It Fl r 110Print the terminal type to the standard error output. 111.It Fl S 112Print the terminal type and the termcap entry to the standard output. 113See the section below on setting the environment for details. 114.It Fl s 115Print the sequence of shell commands to initialize the environment variables 116.Ev TERM 117and 118.Ev TERMCAP 119to the standard output. 120See the section below on setting the environment for details. 121.El 122.Pp 123The arguments for the 124.Fl e , 125.Fl i 126and 127.Fl k 128options may either be entered as actual characters or by using the 129.Dq hat 130notation, i.e. control-h may be specified as 131.Dq Li ^H 132or 133.Dq Li ^h . 134.Sh SETTING THE ENVIRONMENT 135It is often desirable to enter the terminal type and information about 136the terminal's capabilities into the shell's environment. 137This is done using the 138.Fl S 139and 140.Fl s 141options. 142.Pp 143When the 144.Fl S 145option is specified, the terminal type and the termcap entry are written 146to the standard output, separated by a space and without a terminating 147newline. 148This can be assigned to an array by 149.Nm csh 150and 151.Nm ksh 152users and then used like any other shell array. 153.Pp 154When the 155.Fl s 156option is specified, the commands to enter the information into the 157shell's environment are written to the standard output. 158If the 159.Ev SHELL 160environmental variable ends in ``csh'', the commands are for the 161.Nm csh , 162otherwise, they are for 163.Xr sh . 164Note, the 165.Nm csh 166commands set and unset the shell variable 167.Dq noglob , 168leaving it unset. 169The following line in the 170.Pa .login 171or 172.Pa .profile 173files will initialize the environment correctly: 174.Bd -literal -offset indent 175eval \`tset -s options ... \` 176.Ed 177.Pp 178To demonstrate a simple use of the 179.Fl S 180option, the following lines in the 181.Pa .login 182file have an equivalent effect: 183.Bd -literal -offset indent 184set noglob 185set term=(`tset -S options ...`) 186setenv TERM $term[1] 187setenv TERMCAP "$term[2]" 188unset term 189unset noglob 190.Ed 191.Sh TERMINAL TYPE MAPPING 192When the terminal is not hardwired into the system (or the current system 193information is incorrect) the terminal type derived from the 194.Pa /etc/ttys 195file or the 196.Ev TERM 197environmental variable is often something generic like 198.Dq network , 199.Dq dialup , 200or 201.Dq unknown . 202When 203.Nm tset 204is used in a startup script 205.Pf ( Pa .profile 206for 207.Xr sh 1 208users or 209.Pa .login 210for 211.Xr csh 1 212users) it is often desirable to provide information about the type of 213terminal used on such ports. 214The purpose of the 215.Fl m 216option is to 217.Dq map 218from some set of conditions to a terminal type, that is, to 219tell 220.Nm tset 221``If I'm on this port at a particular speed, guess that I'm on that 222kind of terminal''. 223.Pp 224The argument to the 225.Fl m 226option consists of an optional port type, an optional operator, an optional 227baud rate specification, an optional colon (``:'') character and a terminal 228type. 229The port type is a string (delimited by either the operator or the colon 230character). 231The operator may be any combination of: 232.Dq Li \&> , 233.Dq Li \&< , 234.Dq Li \&@ , 235and 236.Dq Li \&! ; 237.Dq Li \&> 238means greater than, 239.Dq Li \&< 240means less than, 241.Dq Li \&@ 242means equal to 243and 244.Dq Li \&! 245inverts the sense of the test. 246The baud rate is specified as a number and is compared with the speed 247of the standard error output (which should be the control terminal). 248The terminal type is a string. 249.Pp 250If the terminal type is not specified on the command line, the 251.Fl m 252mappings are applied to the terminal type. 253If the port type and baud rate match the mapping, the terminal type specified 254in the mapping replaces the current type. 255If more than one mapping is specified, the first applicable mapping is used. 256.Pp 257For example, consider the following mapping: 258.Dq Li dialup>9600:vt100 . 259The port type is 260.Dq Li dialup , 261the operator is 262.Dq Li > , 263the baud rate specification is 264.Dq Li 9600 , 265and the terminal type is 266.Dq Li vt100 . 267The result of this mapping is to specify that if the terminal type is 268.Dq Li dialup , 269and the baud rate is greater than 9600 baud, a terminal type of 270.Dq Li vt100 271will be used. 272.Pp 273If no port type is specified, the terminal type will match any port type, 274for example, 275.Dq Li -m dialup:vt100 -m :?xterm 276will cause any dialup port, regardless of baud rate, to match the terminal 277type 278.Dq Li vt100 , 279and any non-dialup port type to match the terminal type 280.Dq Li ?xterm . 281Note, because of the leading question mark, the user will be 282queried on a default port as to whether they are actually using an 283.Ar xterm 284terminal. 285.Pp 286No whitespace characters are permitted in the 287.Fl m 288option argument. 289Also, to avoid problems with metacharacters, it is suggested that the entire 290.Fl m 291option argument be placed within single quote characters, and that 292.Nm csh 293users insert a backslash character (``\e'') before any exclamation 294marks (``!''). 295.Sh ENVIRONMENT 296The 297.Nm tset 298command utilizes the 299.Ev SHELL 300and 301.Ev TERM 302environment variables. 303.Sh FILES 304.Bl -tag -width /usr/share/misc/termcap -compact 305.It Pa /etc/ttys 306system port name to terminal type mapping database 307.It Pa /usr/share/misc/termcap 308terminal capability database 309.El 310.Sh SEE ALSO 311.Xr csh 1 , 312.Xr sh 1 , 313.Xr stty 1 , 314.Xr tty 4 , 315.Xr termcap 5 , 316.Xr ttys 5 , 317.Xr environ 7 318.Sh HISTORY 319The 320.Nm tset 321command appeared in 322.Bx 3.0 . 323.Sh COMPATIBILITY 324The 325.Fl A , 326.Fl E , 327.Fl h , 328.Fl u 329and 330.Fl v 331options have been deleted from the 332.Nm tset 333utility. 334None of them were documented in 4.3BSD and all are of limited utility at 335best. 336The 337.Fl a , 338.Fl d 339and 340.Fl p 341options are similarly not documented or useful, but were retained as they 342appear to be in widespread use. 343It is strongly recommended that any usage of these three options be 344changed to use the 345.Fl m 346option instead. 347The 348.Fl n 349option remains, but has no effect. 350It is still permissible to specify the 351.Fl e , 352.Fl i 353and 354.Fl k 355options without arguments, although it is strongly recommended that such 356usage be fixed to explicitly specify the character. 357.Pp 358Executing 359.Nm tset 360as 361.Nm reset 362no longer implies the 363.Fl Q 364option. 365Also, the interaction between the 366.Fl 367option and the 368.Ar terminal 369argument in some historic implementations of 370.Nm tset 371has been removed. 372.Pp 373Finally, the 374.Nm tset 375implementation has been completely redone (as part of the addition to the 376system of a 377.St -p1003.1-88 378compliant terminal interface) and will no longer compile on systems with 379older terminal interfaces. 380