home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 5.9 Setting Your Erase, Kill, and Interrupt Characters Chapter 5
Setting Up Your Terminal
Next: 5.11 Initializing the Terminal with tset
 

5.10 Finding What Terminal Names You Can Use

A program that wants to make use of the terminal capability database selects an entry according to the value of the TERM environment variable ( 6.1 ) . This variable is typically set when a user logs in. A second variable, either TERMCAP ( 5.4 ) or TERMINFO , may also be set, if it is desirable to point to a terminal description that is not in the standard location.

It's easy enough to find out what terminal type the system thinks you are currently using. Simply type:

$ 

echo $TERM

If nothing is printed, TERM has not been set. (In the C shell, the message TERM: Undefined variable will be printed.)

It's also easy enough to set the terminal type. This is typically done when the user logs in but can be done from the command line as follows:

$ 

TERM=wy50; export TERM


% 

setenv TERM wy50

But what if you sit down at a strange terminal and want to set the terminal type? How do you know what terminal name to use as the value of TERM ?

The terminal names to which TERM can legitimately be set can be determined by searching through /etc/termcap or by listing the names of files in the /usr/lib/terminfo directory hierarchy.

The termcap terminal database is stored in the single file /etc/termcap . It is an ASCII file: all the information it contains is readable, if not immediately comprehensible. Each entry consists of a list of names for the terminal, followed by a list of the terminal's capabilities.

The first line of each entry shows several different names, or aliases, for the terminal. At least one of the names will usually reflect the manufacturer's shorthand name for the terminal, but a long name is usually included as well, so you can simply search for the manufacturer's name to get started. For example, if you were using a Wyse Technologies Wyse-50, you could check to make sure that a terminal description for that terminal existed in the termcap database by typing:

% 

grep Wyse /etc/termcap


n9|wy50|Wyse Technology WY-50:\

One or more lines like the one shown in the preceding example should be printed (if any matching entries are found). Each line will show several names for the terminal, separated by vertical bars ( | ). The second name, wy50 , is the one most commonly used as the value of TERM .

The compiled terminfo database is stored in a directory hierarchy under /usr/lib/terminfo . Each terminal entry is compiled (by a program called tic ) and stored in a separate file. All terminals whose names begin with the letter "a" are stored in the directory /usr/lib/terminfo/a , and so on through the alphabet. [1] Links ( 18.3 ) are used so that the terminal description can be accessed with any one of several names. [The ls -R ( 16.4 ) command will list all the descriptions at once. A command like find -name '*xxx*' -print ( 17.4 ) will find descriptions with a certain brand or model xxx in the name. -JP  ]

[1] The source is sometimes provided by some systems in /usr/lib/terminfo.ti . Entries can be decompiled or displayed with a program called infocmp .

So, on a system supporting terminfo , you would look for the entry with the ls command:

$ 

ls /usr/lib/terminfo/w


wy-50
wy100
wy50
wyse-50
wyse50

You should use the name of the appropriate file for the value of TERM .

If it is not obvious from the name of the file which entry to use, you can use the following command to print out the long name of the terminal:

$ 

tput -T



name

 

longname

For example:

$ 

tput -Twy50 longname


Wyse Technologies Wy-50

You should be aware that for a terminal with configurable options (such as a terminal with an 80- or 132-column mode), there may be several termcap or terminfo entries. Until you know enough about the terminal database to compare the entries and find out how they differ, you will simply need to take your chances. Experiment with each of the entries and see which works best. Article 41.11 explains more about the format of termcap and terminfo entries. [If none of them seem to work, setting TERM to a name like dumb or unknown will give you a basic setup while you check other entries. The vi editor will use its open mode ( 30.36 ) and pagers like less ( 25.4 ) will complain a little, but you should be able to get by. -JP  ]

- TOR from O'Reilly & Associates' termcap & terminfo , Chapter 2


Previous: 5.9 Setting Your Erase, Kill, and Interrupt Characters UNIX Power Tools Next: 5.11 Initializing the Terminal with tset
5.9 Setting Your Erase, Kill, and Interrupt Characters Book Index 5.11 Initializing the Terminal with tset

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System