1.\" Copyright (c) 1985, 1990 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" %sccs.include.redist.roff% 5.\" 6.\" @(#)tset.1 6.7 (Berkeley) 07/27/91 7.\" 8.Dd 9.Dt TSET 1 10.Os BSD 4 11.Sh NAME 12.Nm tset 13.Nd terminal dependent initialization 14.Sh SYNOPSIS 15.Nm tset 16.Op Ar options 17.Oo 18.Fl m 19.Oo 20.Ar ident 21.Oc Ns Oo 22.Ar test baudrate 23.Oc Ns Cm \&: Ns Ar type 24.Oc ... 25.Op type 26.Nm reset 27.Op Ar options 28.Oo 29.Fl m 30.Oo 31.Ar ident 32.Oc Ns Oo 33.Ar test baudrate 34.Oc Ns Cm \&: Ns Ar type 35.Oc ... 36.Op type 37.Sh DESCRIPTION 38.Nm Tset 39sets up your terminal when you first log in to a 40.Tn UNIX 41system. 42It does terminal dependent processing such as setting 43erase and kill characters, setting or resetting delays, 44sending any sequences needed to properly initialized the terminal, 45and the like. 46It first determines the 47.Ar type 48of terminal involved, 49and then does necessary initializations and mode settings. 50The type of terminal attached to each 51.Tn UNIX 52port is specified in the 53.Xr ttys 5 54database. 55Type names for terminals may be found in the 56.Xr termcap 5 57database. 58If a port is not wired permanently to a specific terminal (not hardwired) 59it will be given an appropriate generic identifier such as 60.Em dialup . 61.Pp 62In the case where no arguments are specified, 63.Nm tset 64simply reads the terminal type out of the environment variable 65.Ev TERM 66and re-initializes the terminal. 67The rest of this manual concerns 68itself with mode and environment initialization, 69typically done once at login, and options 70used at initialization time to determine the terminal type and set up 71terminal modes. 72.Pp 73.Bl -tag -width flag 74.It Fl e Ns Ar c 75set the erase character to be the named character 76.Ar c 77on all terminals, 78the default being the backspace character on the terminal, usually ^H. 79The character 80.Ar c 81can either be typed directly, or entered using the hat 82notation used here. 83.It Fl k Ns Ar c 84is similar to 85.Fl e 86but for the line kill character rather than the erase character; 87.Ar c 88defaults to ^X (for purely historical reasons). 89The kill characters is left alone if 90.Fl k 91is not specified. 92The hat notation can also be used for this option. 93.It Fl i Ns Ar c 94is similar to 95.Fl e 96but for the interrupt character rather than the erase character; 97.Ar c 98defaults to ^C. 99The hat notation can also be used for this option. 100.It Fl 101The name of the terminal finally decided upon is output on the 102standard output. 103This is intended to be captured by the shell and placed in the 104environment variable 105.Ev TERM. 106.It Fl s 107Print the sequence of 108.Xr csh 1 109commands to initialize the environment variables 110.Ev TERM 111and 112.Ev TERMCAP 113based on 114the name of the terminal finally decided upon. 115.It Fl m 116The 117.FL m 118Specify what terminal type to use on specific ports (i.e. map the 119terminal type to a port as found in 120.Xr ttys 5 . ) 121See below. 122.It Fl n 123On systems with the 124.Bx 4 125driver, 126specifies that the new tty driver modes should be initialized for this terminal. 127For a 128.Tn CRT , 129the 130.Dv CRTERASE 131and 132.Dv CRTKILL 133modes are set only if the baud rate is 1200 or greater. 134See 135.Xr tty 4 136for more detail. 137.It Fl I 138suppresses transmitting terminal initialization strings. 139.It Fl Q 140suppresses printing the 141.Dq Li "Erase set to" 142and 143.Dq Li "Kill set to" 144messages. 145.El 146.Pp 147When used in a startup script 148.Pf ( Pa .profile 149for 150.Xr sh 1 151users or 152.Pa .login 153for 154.Xr csh 1 155users) it is desirable to give information about the type of terminal 156you will usually use on ports which are not hardwired. 157These ports are identified in 158.Xr ttys 5 159as 160.Li dialup 161or 162.Li plugboard 163or 164.Li arpanet , 165etc. 166To specify 167what terminal type you usually use on these ports, the 168.Fl m 169(map) option flag is followed by the appropriate port type identifier, 170an optional baud rate specification, 171and the terminal type. 172(The effect is to ``map'' from some conditions to a terminal type, 173that is, to tell 174.Nm tset 175``If I'm on this kind of port, guess that I'm on that kind of terminal''.) 176If more than one mapping is specified, the first applicable mapping prevails. 177A missing port type identifier matches all identifiers. 178Any of the alternate generic names given in 179.Xr termcap 5 180may be used for the identifier. 181.Pp 182A 183.Ar baudrate 184is specified as with 185.Xr stty 1 , 186and is compared with the 187speed of the diagnostic output (which should be the control terminal). 188The baud rate 189.Ar test 190may be any combination of: 191.Cm \&> , 192.Cm \&@ , 193.Cm \&< , 194and 195.Cm \&! ; 196.Cm \&@ 197means ``at'' 198and 199.Cm \&! 200inverts the sense of the test. 201To avoid problems with metacharacters, it 202is best to place the entire argument to 203.Fl m 204within ``\''' characters; users of 205.Xr csh 1 206must also put a ``\e'' before any ``!'' used here. 207.Bd -filled -offset indent 208tset \-m \'dialup>300:adm3a\' -m dialup:dw2 -m \'plugboard:?adm3a\' 209.Ed 210.Pp 211causes the terminal type to be set to an 212.Ar adm3a 213if the port in use is a dialup at a speed greater than 300 baud; 214to a 215.Ar dw2 216if the port is (otherwise) a dialup (i.e. at 300 baud or less). 217.Sy NOTE : 218the examples given here appear to take up more than 219one line, for text processing reasons. 220When you type in real 221.Nm tset 222commands, you must enter them entirely on one line. 223If the 224.Ar type 225finally determined by 226.Nm tset 227begins with a question mark, 228the user is asked if s/he really wants that type. 229A null response means to use that type; 230otherwise, another type can be entered which will be used instead. 231Thus, in the above case, the user will be queried on a plugboard port 232as to whether they are actually using an 233.Ar adm3a . 234.Pp 235If no mapping applies and a final 236.Ar type 237option, not preceded by a 238.Fl m , 239is given on the command line 240then that type is used; 241otherwise the type found in the 242.Xr ttys 5 243database will be taken to be the terminal type. 244This should always be the case for hardwired ports. 245.Pp 246It is usually desirable to return the terminal type, as finally determined by 247.Nm tset , 248and information about the terminal's capabilities 249to a shell's environment. 250This can be done using the 251.Fl 252option; using the Bourne shell, 253.Xr \&sh 1 : 254.Bd -literal -offset indent 255export TERM; TERM=\`tset options ... \` 256.Ed 257.Pp 258or using the C shell, 259.Xr csh 1 : 260.Bd -literal -offset indent 261setenv TERM \`tset \- options ... \` 262.Ed 263.Pp 264With 265.Xr csh 1 266it is preferable to use the following command in one's 267.Pa .login 268file to 269initialize the 270.Ev TERM 271and 272.Ev TERMCAP 273environment variables at the same time. 274.Bd -literal -offset indent 275eval \`tset -s options ... \` 276.Ed 277.Pp 278It is also convenient to make an alias in your .cshrc: 279.Bd -literal -offset indent 280alias tset \'eval \`tset \-s \e!*\`\' 281.Ed 282.Pp 283This allows the command: 284.Pp 285.Dl tset 2621 286.Pp 287to be invoked at any time to set the terminal and environment. 288.Sy Note to Bourne Shell users: 289It is 290.Em not 291possible to get this aliasing effect with a shell script, 292because shell scripts cannot set the environment of their parent. 293(If a process could set its parent's environment, 294none of this nonsense would be necessary in the first place.) 295.Pp 296These commands cause 297.Nm tset 298to place the name of your terminal in the variable 299.Ev TERM 300in the environment; see 301.Xr environ 7 . 302.Pp 303Once the terminal type is known, 304.Nm tset 305engages in terminal driver mode setting. 306This normally involves sending an initialization sequence to the 307terminal, setting the single character erase (and optionally 308the line-kill (full line erase)) characters, 309and setting special character delays. 310Tab and newline expansion are turned off during transmission of 311the terminal initialization sequence. 312.Pp 313On terminals that can backspace but not overstrike 314(such as a 315.Tn CRT ) , 316and when the erase character is the default erase character 317(`#' on standard systems), 318the erase character is changed to 319.Dv BACKSPACE 320(Control-H). 321.Pp 322If 323.Nm tset 324is invoked as 325.Nm reset , 326it will set cooked and echo modes, turn off cbreak and raw modes, 327turn on newline translation, and restore special characters 328to a sensible state before any terminal dependent processing is done. 329Any special character that is found to be 330.Tn NULL 331or ``\-1'' is reset to its default value. 332All arguments to 333.Nm tset 334may be used with reset. 335.Pp 336This is most useful after a program dies leaving a terminal in a funny 337state. 338You may have to type 339.Dq Li <LF>reset<LF> 340to get it to work 341since 342.Li <CR> 343may not work in this state. 344Often none of this will echo. 345.Sh EXAMPLES 346.Pp 347These examples all assume the Bourne shell and use the 348.Fl 349option. 350If you use 351.Xr csh , 352use one of the variations described above. 353Note that a typical use of 354.Nm tset 355in a 356.Pa .profile 357or 358.Pa .login 359will also use the 360.Fl e 361and 362.Fl k 363options, and often the 364.Fl n 365or 366.Fl Q 367options as well. 368These options have not been included here to keep the examples small. 369.Sy NOTE : 370some of the examples given here appear to take up more than 371one line, for text processing reasons. 372When you type in real 373.Nm tset 374commands, you must enter them entirely on one line. 375.Pp 376At the moment, you are on a 377.Li 2621 . 378This is suitable for typing by hand but 379not for a 380.Pa .profile, unless you are 381.Em always 382on a 2621. 383.Bd -literal -offset indent 384export TERM; TERM=\`tset \- 2621\` 385.Ed 386.Pp 387You have an h19 at home which you dial up on, but your office terminal 388is hardwired and known in 389.Xr ttys 5 . 390.Bd -literal -offset indent 391export TERM; TERM=\`tset \- \-m dialup:h19\` 392.Ed 393.Pp 394You have a switch which connects everything to everything, making 395it nearly impossible to key on what port you are coming in on. 396You use a vt100 in your office at 9600 baud, and dial up to switch 397ports at 1200 baud from home on a 2621. 398Sometimes you use someone elses terminal at work, 399so you want it to ask you to make sure what terminal 400type you have at high speeds, but at 1200 baud you are 401always on a 2621. 402Note the placement of the question mark, and the quotes 403to protect the greater than and question mark from 404interpretation by the shell. 405.Bd -literal -offset indent 406export TERM; TERM=\`tset \- \-m 'switch>1200:?vt100'\e 407\-m 'switch<=1200:2621' 408.Ed 409.Pp 410All of the above entries will fall back on the terminal type 411specified in 412.Xr ttys 5 413if none of the conditions hold. 414The following entry is appropriate if 415you always dial up, always at the same baud rate, 416on many different kinds of terminals. 417Your most common terminal is an adm3a. 418It always asks you what kind of terminal you are on, 419defaulting to adm3a. 420.Bd -literal -offset indent 421export TERM; TERM=\`tset \- ?adm3a\` 422.Ed 423.Pp 424If the file 425.Xr ttys 5 426is not properly installed and you want to 427key entirely on the baud rate, the following can be used: 428.Bd -literal -offset indent 429export TERM; TERM=\`tset \- \-m '>1200:vt100' 2621\` 430.Ed 431.Pp 432Here is a fancy example to illustrate the power of 433.Nm tset 434and to hopelessly confuse anyone who has made it this far. 435You dial up at 1200 baud or less on a concept100, 436sometimes over switch ports and sometimes over regular dialups. 437You use various terminals at speeds higher than 1200 over switch ports, 438most often the terminal in your office, which is a vt100. 439However, sometimes you log in from the university you used to go to, 440over the 441.Tn ARPANET ; 442in this case you are on an 443.Tn ALTO 444emulating a dm2500. 445You also often log in on various hardwired ports, such as the console, 446all of which are properly entered in 447.Xr ttys 5 . 448You want your erase character set to control H, 449your kill character set to control U, 450and don't want 451.Nm tset 452to print the 453.Dq Li Erase set to Backspace , 454.Dq Li Kill set to Control U 455message. 456.Bd -literal -offset indent 457export TERM; TERM=\`tset \-e \-k^U \-Q \-\e 458\-m 'switch<=1200:concept100' \-m 'switch:?vt100'\e 459\-m dialup:concept100 \-m arpanet:dm2500\` 460.Ed 461.Sh ENVIRONMENT 462The 463.Nm tset 464command utilizes the 465.Ev TERM 466and 467.Ev TERMCAP 468environment variables. 469.Sh FILES 470.Bl -tag -width /usr/share/misc/termcap -compact 471.It Pa /etc/ttys 472port name to terminal type mapping database 473.It Pa /usr/share/misc/termcap 474terminal capability database 475.El 476.Sh SEE ALSO 477.Xr csh 1 , 478.Xr sh 1 , 479.Xr stty 1 , 480.Xr ttys 5 , 481.Xr termcap 5 , 482.Xr environ 7 483.Sh HISTORY 484The 485.Nm tset 486command appeared in 487.Bx 3.0 . 488.Sh BUGS 489.Pp 490The 491.Nm tset 492command is one of the first commands a user must master when getting 493started on a 494.Tn UNIX 495system. 496Unfortunately, it is one of the most complex, 497largely because of the extra effort the user must go through 498to get the environment of the login shell set. 499Something needs to be done to make all this simpler, 500either the 501.Xr login 1 502program should do this stuff, 503or a default shell alias should be made, 504or a way to set the environment of the parent should exist. 505.Pp 506This program can't intuit personal choices for erase, interrupt 507and line kill characters, so it leaves these set to the local system 508standards. 509.\" .ig 510.\" .Sh NOTES 511.\" For compatibility with earlier versions of 512.\" .Nm tset 513.\" a number of flags are accepted whose use is discouraged: 514.\" .Bl -tag -width Fl 515.\" .It Fl d Ns Ar type 516.\" equivalent to 517.\" .Fl m 518.\" .Ar dialup:type 519.\" .It Fl p Ns Ar type 520.\" equivalent to 521.\" .Fl m 522.\" .Ar plugboard:type 523.\" .It Fl a Ns Ar type 524.\" equivalent to 525.\" .Fl m 526.\" .Ar arpanet:type 527.\" .It Fl E Ns Ar c 528.\" Sets the erase character to 529.\" .Ar c 530.\" only if the terminal can backspace. 531.\" .It Fl 532.\" prints the terminal type on the standard output 533.\" .It Fl r 534.\" prints the terminal type on the diagnostic output. 535.\" .El 536