TSET(1) UNIX Programmer's Manual TSET(1) NAME tset, reset - set terminal modes SYNOPSIS tset [ options ] [ -m [ident][test baudrate]:type ] ... [ type ] reset ... DESCRIPTION _T_s_e_t sets up your terminal when you first log in to a UNIX system. It does terminal dependent processing such as set- ting erase and kill characters, setting or resetting delays, and the like. It first determines the _t_y_p_e of terminal involved, and then does necessary initializations and mode settings. The type of terminal attached to each UNIX port is specified in the /_e_t_c/_t_t_y_t_y_p_e database. Type names for terminals may be found in the /_e_t_c/_t_e_r_m_c_a_p database. If a port is not wired permanently to a specific terminal (not hardwired) it will be given an appropriate generic identif- ier such as _d_i_a_l_u_p. In the case where no arguments are specified, _t_s_e_t simply reads the terminal type out of the environment variable TERM and reinitializes the terminal. The rest of this manual concerns itself with mode and environment initialization, typically done once at login, and options used at initiali- zation time to determine the terminal type and set up termi- nal modes. When used in a startup script (._p_r_o_f_i_l_e for _s_h(1) users or ._l_o_g_i_n for _c_s_h(1) users) it is desirable to give information about the type of terminal you will usually use on ports which are not hardwired. These ports are identified in /_e_t_c/_t_t_y_t_y_p_e as _d_i_a_l_u_p or _p_l_u_g_b_o_a_r_d or _a_r_p_a_n_e_t, etc. To specify what terminal type you usually use on these ports, the -m (map) option flag is followed by the appropriate port type identifier, an optional baud rate specification, and the terminal type. (The effect is to ``map'' from some con- ditions to a terminal type, that is, to tell _t_s_e_t ``If I'm on this kind of port, guess that I'm on that kind of termi- nal''.) If more than one mapping is specified, the first applicable mapping prevails. A missing port type identifier matches all identifiers. Any of the alternate generic names given in _t_e_r_m_c_a_p may be used for the identifier. A _b_a_u_d_r_a_t_e is specified as with _s_t_t_y(1), and is compared with the speed of the diagnostic output (which should be the control terminal). The baud rate _t_e_s_t may be any combina- tion of: >, @, <, and !; @ means ``at'' and ! inverts the sense of the test. To avoid problems with metacharacters, it is best to place the entire argument to -m within ``''' Printed 8/5/83 1 TSET(1) UNIX Programmer's Manual TSET(1) characters; users of _c_s_h(1) must also put a ``\'' before any ``!'' used here. Thus tset -m 'dialup>300:adm3a' -m dialup:dw2 -m 'plugboard:?adm3a' causes the terminal type to be set to an _a_d_m_3_a if the port in use is a dialup at a speed greater than 300 baud; to a _d_w_2 if the port is (otherwise) a dialup (i.e. at 300 baud or less). (NOTE: the examples given here appear to take up more than one line, for text processing reasons. When you type in real _t_s_e_t commands, you must enter them entirely on one line.) If the _t_y_p_e finally determined by _t_s_e_t begins with a question mark, the user is asked if s/he really wants that type. A null response means to use that type; other- wise, another type can be entered which will be used instead. Thus, in the above case, the user will be queried on a plugboard port as to whether they are actually using an _a_d_m_3_a. If no mapping applies and a final _t_y_p_e option, not preceded by a -m, is given on the command line then that type is used; otherwise the identifier found in the /_e_t_c/_t_t_y_t_y_p_e database will be taken to be the terminal type. This should always be the case for hardwired ports. It is usually desirable to return the terminal type, as finally determined by _t_s_e_t, and information about the terminal's capabilities to a shell's environment. This can be done using the -s option; using the Bourne shell, _s_h(1): eval `tset -s _o_p_t_i_o_n_s...` or using the C shell, _c_s_h(1): set noglob; eval `tset -s _o_p_t_i_o_n_s...` If you have an old csh with no eval command, do the follow- ing: tset -s options > /tmp/tset$$ ; source /tmp/tset$$ ; rm /tmp/tset$$ In either _c_s_h case, you should probably make an alias in your .cshrc: alias tset 'set noglob; eval `tset -s *`' or Printed 8/5/83 2 TSET(1) UNIX Programmer's Manual TSET(1) alias tset 'tset -s * > /tmp/tset$$ ; source /tmp/tset$$ ; rm /tmp/tset$$' Either of these aliases allow the command tset 2621 to be invoked at any time from your login csh. Note to Bourne Shell users: It is _n_o_t possible to get this aliasing effect with a shell script, because shell scripts cannot set the environment of their parent. (If a process could set its parent's environment, none of this nonsense would be necessary in the first place.) These commands cause _t_s_e_t to generate as output a sequence of shell commands which place the variables TERM and TERMCAP in the environment; see _e_n_v_i_r_o_n(5). Once the terminal type is known, _t_s_e_t engages in terminal driver mode setting. This normally involves sending an ini- tialization sequence to the terminal, setting the single character erase (and optionally the line-kill (full line erase)) characters, and setting special character delays. Tab and newline expansion are turned off during transmission of the terminal initialization sequence. On terminals that can backspace but not overstrike (such as a CRT), and when the erase character is the default erase character (`#' on standard systems), the erase character is changed to BACKSPACE (Control-H). The options are: -e_c set the erase character to be the named character _c on all terminals, the default being the backspace charac- ter on the terminal, usually ^H. The character _c can either be typed directly, or entered using the hat notation used here. -k_c is similar to -e but for the line kill character rather than the erase character; _c defaults to ^X (for purely historical reasons). The kill characters is left alone if -k is not specified. The hat notation can also be used for this option. -n On systems with the Berkeley 4BSD tty driver, specifies that the new tty driver modes should be initialized for this terminal. For a CRT, the CRTERASE and CRTKILL modes are set only if the baud rate is 1200 or greater. See newtty(4) for more detail. -v On systems with CB/UNIX virtual terminals, normally _t_s_e_t sets up the tty driver modes and the environment TERMCAP variable to use the virtual terminal. The -v option turns off this processing, causing tset to not Printed 8/5/83 3 TSET(1) UNIX Programmer's Manual TSET(1) use a virtual terminal. -I suppresses transmitting terminal initialization strings. -Q supresses printing the ``Erase set to'' and ``Kill set to'' messages. -S If your shell is _c_s_h, _t_s_e_t will output the strings to be assigned to TERM and TERMCAP in the environment rather than commands for a shell. This is mainly use- ful to avoid the (slow) source command with an old _c_s_h. If _t_s_e_t is invoked as _r_e_s_e_t, it will set cooked and echo modes, turn off cbreak and raw modes, turn on newline trans- lation, and restore special characters to a sensible state before any terminal dependent processing is done. Any spe- cial character that is found to be NULL or ``-1'' is reset to it's default value. This is most useful after a program dies leaving a terminal in a funny state. You may have to type ``reset'' to get it to work since may not work in this state. Often none of this will echo. EXAMPLES These examples all assume the Bourne shell and use the -s option. If you use _c_s_h, use one of the variations described above. Note that a typical use of _t_s_e_t in a .profile or .login will also use the -e and -k options, and often the -n or -Q options as well. These options have not been included here to keep the examples small. (NOTE: some of the exam- ples given here appear to take up more than one line, for text processing reasons. When you type in real _t_s_e_t com- mands, you must enter them entirely on one line.) At the moment, you are on a 2621. This is suitable for typ- ing by hand but not for a .profile, unless you are _a_l_w_a_y_s on a 2621. eval `tset -s 2621` You have an h19 at home which you dial up on, but your office terminal is hardwired and known in /etc/ttytype. eval `tset -s -m dialup:h19` You have a switch which connects everything to everything, making it nearly impossible to key on what port you are com- ing in on. You use a vt100 in your office at 9600 baud, and Printed 8/5/83 4 TSET(1) UNIX Programmer's Manual TSET(1) dial up to switch ports at 1200 baud from home on a 2621. Sometimes you use someone elses terminal at work, so you want it to ask you to make sure what terminal type you have at high speeds, but at 1200 baud you are always on a 2621. Note the placement of the question mark, and the quotes to protect the greater than and question mark from interpreta- tion by the shell. eval `tset -s -m 'switch>1200:?vt100' -m 'switch<=1200:2621' All of the above entries will fall back on the terminal type specified in /etc/ttytype if none of the conditions hold. The following entry is appropriate if you always dial up, always at the same baud rate, on many different kinds of terminals. Your most common terminal is an adm3a. It always asks you what kind of terminal you are on, defaulting to adm3a. eval `tset -s ?adm3a` If the file /etc/ttytype is not properly installed and you want to key entirely on the baud rate, the following can be used: eval `tset -s -m '>1200:vt100' 2621` Here is a fancy example to illustrate the power of _t_s_e_t and to hopelessly confuse anyone who has made it this far. You dial up at 1200 baud or less on a concept100, sometimes over switch ports and sometimes over regular dialups. You use various terminals at speeds higher than 1200 over switch ports, most often the terminal in your office, which is a vt100. However, sometimes you log in from the university you used to go to, over the ARPANET; in this case you are on an ALTO emulating a dm2500. You also often log in on vari- ous hardwired ports, such as the console, all of which are properly entered in /etc/ttytype. You want your erase char- acter set to control H, your kill character set to control U, and don't want _t_s_e_t to print the ``Erase set to Back- space, Kill set to Control U'' message. eval `tset -e -k^U -Q -s -m 'switch<=1200:concept100' -m 'switch:?vt100' -m dialup:concept100 -m arpanet:dm2500` FILES /etc/ttytype port name to terminal type mapping data- base /etc/termcap terminal capability database Printed 8/5/83 5 TSET(1) UNIX Programmer's Manual TSET(1) SEE ALSO csh(1), sh(1), stty(1), environ(5), termcap(5), ttytype(5) AUTHOR Eric Allman David Wasley Mark Horton BUGS The _t_s_e_t command is one of the first commands a user must master when getting started on a UNIX system. Unfor- tunately, it is one of the most complex, largely because of the extra effort the user must go through to get the environment of the login shell set. Something needs to be done to make all this simpler, either the _l_o_g_i_n(1) program should do this stuff, or a default shell alias should be made, or a way to set the environment of the parent should exist. Printed 8/5/83 6