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