BSD 4_3_Tahoe development
[unix-history] / usr / man / cat1 / reset.0
TSET(1) UNIX Programmer's Manual TSET(1)
N\bNA\bAM\bME\bE
tset - terminal dependent initialization
S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS
t\bts\bse\bet\bt [ options ] [ -\b-m\bm [ident][test baudrate]:type ] ... [
type ]
r\bre\bes\bse\bet\bt [ options ] [ -\b-m\bm [ident][test baudrate]:type ] ... [
type ]
D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
_\bT_\bs_\be_\bt 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,
sending any sequences needed to properly initialized the
terminal, and the like. It first determines the _\bt_\by_\bp_\be of
terminal involved, and then does necessary initializations
and mode settings. The type of terminal attached to each
UNIX port is specified in the /_\be_\bt_\bc/_\bt_\bt_\by_\bs(5) database. Type
names for terminals may be found in the _\bt_\be_\br_\bm_\bc_\ba_\bp(5) database.
If a port is not wired permanently to a specific terminal
(not hardwired) it will be given an appropriate generic
identifier such as _\bd_\bi_\ba_\bl_\bu_\bp.
In the case where no arguments are specified, _\bt_\bs_\be_\bt simply
reads the terminal type out of the environment variable TERM
and re-initializes 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 (._\bp_\br_\bo_\bf_\bi_\bl_\be for _\bs_\bh(1) users or
._\bl_\bo_\bg_\bi_\bn for _\bc_\bs_\bh(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
/_\be_\bt_\bc/_\bt_\bt_\by_\bs as _\bd_\bi_\ba_\bl_\bu_\bp or _\bp_\bl_\bu_\bg_\bb_\bo_\ba_\br_\bd or _\ba_\br_\bp_\ba_\bn_\be_\bt, etc. To
specify what terminal type you usually use on these ports,
the -\b-m\bm (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 _\bt_\bs_\be_\bt ``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 _\bt_\be_\br_\bm_\bc_\ba_\bp may be used for the identifier.
A _\bb_\ba_\bu_\bd_\br_\ba_\bt_\be is specified as with _\bs_\bt_\bt_\by(1), and is compared
with the speed of the diagnostic output (which should be the
control terminal). The baud rate _\bt_\be_\bs_\bt may be any combina-
tion of: >\b>, @\b@, <\b<, and !\b!; @\b@ means ``at'' and !\b! inverts the
Printed 7/9/88 May 5, 1986 1
TSET(1) UNIX Programmer's Manual TSET(1)
sense of the test. To avoid problems with metacharacters,
it is best to place the entire argument to -\b-m\bm within ``'''
characters; users of _\bc_\bs_\bh(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 _\ba_\bd_\bm_\b3_\ba if the port
in use is a dialup at a speed greater than 300 baud; to a
_\bd_\bw_\b2 if the port is (otherwise) a dialup (i.e. at 300 baud or
less). (N\bNO\bOT\bTE\bE:\b: the examples given here appear to take up
more than one line, for text processing reasons. When you
type in real _\bt_\bs_\be_\bt commands, you must enter them entirely on
one line.) If the _\bt_\by_\bp_\be finally determined by _\bt_\bs_\be_\bt 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
_\ba_\bd_\bm_\b3_\ba.
If no mapping applies and a final _\bt_\by_\bp_\be option, not preceded
by a -\b-m\bm, is given on the command line then that type is
used; otherwise the type found in the /_\be_\bt_\bc/_\bt_\bt_\by_\bs 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 _\bt_\bs_\be_\bt, and information about the
terminal's capabilities to a shell's environment. This can
be done using the -\b- option; using the Bourne shell, _\bs_\bh(1):
export TERM; TERM=`tset - _\bo_\bp_\bt_\bi_\bo_\bn_\bs...`
or using the C shell, _\bc_\bs_\bh(1):
setenv TERM `tset - _\bo_\bp_\bt_\bi_\bo_\bn_\bs...`
With _\bc_\bs_\bh it is preferable to use the following command in
your .login file to initialize the TERM and TERMCAP environ-
ment variables at the same time.
eval `tset -s _\bo_\bp_\bt_\bi_\bo_\bn_\bs...`
It is also convenient to make an alias in your .cshrc:
alias tset 'eval `tset -s \!*`'
Printed 7/9/88 May 5, 1986 2
TSET(1) UNIX Programmer's Manual TSET(1)
This allows the command:
tset 2621
to be invoked at any time to set the terminal and environ-
ment. N\bNo\bot\bte\be t\bto\bo B\bBo\bou\bur\brn\bne\be S\bSh\bhe\bel\bll\bl u\bus\bse\ber\brs\bs:\b: It is n\bno\bot\bt 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 _\bt_\bs_\be_\bt to place the name of your terminal
in the variable TERM in the environment; see _\be_\bn_\bv_\bi_\br_\bo_\bn(7).
Once the terminal type is known, _\bt_\bs_\be_\bt 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:
-\b-e\be_\bc set the erase character to be the named character _\bc on
all terminals, the default being the backspace charac-
ter on the terminal, usually ^H. The character _\bc can
either be typed directly, or entered using the hat
notation used here.
-\b-k\bk_\bc is similar to -\b-e\be but for the line kill character rather
than the erase character; _\bc defaults to ^X (for purely
historical reasons). The kill characters is left alone
if -\b-k\bk is not specified. The hat notation can also be
used for this option.
-\b-i\bi_\bc is similar to -\b-e\be but for the interrupt character rather
than the erase character; _\bc defaults to ^C. The hat
notation can also be used for this option.
-\b- The name of the terminal finally decided upon is output
on the standard output. This is intended to be cap-
tured by the shell and placed in the environment vari-
able TERM.
-\b-s\bs Print the sequence of _\bc_\bs_\bh commands to initialize the
environment variables TERM and TERMCAP based on the
Printed 7/9/88 May 5, 1986 3
TSET(1) UNIX Programmer's Manual TSET(1)
name of the terminal finally decided upon.
-\b-n\bn 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 tty(4) for more detail.
-\b-I\bI suppresses transmitting terminal initialization
strings.
-\b-Q\bQ suppresses printing the ``Erase set to'' and ``Kill set
to'' messages.
If t\bts\bse\bet\bt is invoked as r\bre\bes\bse\bet\bt, 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 its default value. All arguments to _\bt_\bs_\be_\bt may be used
with reset.
This is most useful after a program dies leaving a terminal
in a funny state. You may have to type ``<LF>reset<LF>'' to
get it to work since <CR> may not work in this state. Often
none of this will echo.
E\bEX\bXA\bAM\bMP\bPL\bLE\bES\bS
These examples all assume the Bourne shell and use the -
option. If you use _\bc_\bs_\bh, use one of the variations described
above. Note that a typical use of _\bt_\bs_\be_\bt in a .profile or
.login will also use the -\b-e\be and -\b-k\bk options, and often the -\b-n\bn
or -\b-Q\bQ options as well. These options have not been included
here to keep the examples small. (N\bNO\bOT\bTE\bE:\b: some of the exam-
ples given here appear to take up more than one line, for
text processing reasons. When you type in real _\bt_\bs_\be_\bt 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 _\ba_\bl_\bw_\ba_\by_\bs on
a 2621.
export TERM; TERM=`tset - 2621`
You have an h19 at home which you dial up on, but your
office terminal is hardwired and known in /etc/ttys.
export TERM; TERM=`tset - -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 7/9/88 May 5, 1986 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.
export TERM; TERM=`tset - -m 'switch>1200:?vt100' -m
'switch<=1200:2621'
All of the above entries will fall back on the terminal type
specified in /_\be_\bt_\bc/_\bt_\bt_\by_\bs 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.
export TERM; TERM=`tset - ?adm3a`
If the file /_\be_\bt_\bc/_\bt_\bt_\by_\bs is not properly installed and you want
to key entirely on the baud rate, the following can be used:
export TERM; TERM=`tset - -m '>1200:vt100' 2621`
Here is a fancy example to illustrate the power of _\bt_\bs_\be_\bt 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 /_\be_\bt_\bc/_\bt_\bt_\by_\bs. You want your erase charac-
ter set to control H, your kill character set to control U,
and don't want _\bt_\bs_\be_\bt to print the ``Erase set to Backspace,
Kill set to Control U'' message.
export TERM; TERM=`tset -e -k^U -Q - -m
'switch<=1200:concept100' -m 'switch:?vt100' -m
dialup:concept100 -m arpanet:dm2500`
F\bFI\bIL\bLE\bES\bS
/etc/ttys port name to terminal type mapping database
/etc/termcap terminal capability database
S\bSE\bEE\bE A\bAL\bLS\bSO\bO
csh(1), sh(1), stty(1), ttys(5), termcap(5), environ(7)
Printed 7/9/88 May 5, 1986 5
TSET(1) UNIX Programmer's Manual TSET(1)
B\bBU\bUG\bGS\bS
The _\bt_\bs_\be_\bt 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 _\bl_\bo_\bg_\bi_\bn(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.
This program can't intuit personal choices for erase, inter-
rupt and line kill characters, so it leaves these set to the
local system standards.
Printed 7/9/88 May 5, 1986 6