Using an Appropriate termcap or terminfo

One of the problems faced during the early development of Unix was the wide array of terminal hardware with which the OS had to cope. The codes that would clear the screen on one terminal might have no effect on another, and they would cause a third to perform some wholly inappropriate action. Because of this, programs couldn't be written to use specific terminal codes to perform specific actions. The solution to this problem was to create a database of information on terminal types. Originally, this database was known as termcap, and it relied on data stored in /etc/termcap. Newer programs use a more recent database known as terminfo, which stores data in files in the /usr/share/terminfo directory tree.

In both cases, programs rely upon the TERM environment variable to identify the terminal type. Examples of values this variable might hold include linux (for text-mode Linux logins), xterm (forxterm windows under X), and vt100 (for the popular DEC VT-100 terminal or any terminal or program that emulates it). Type echo $TERM in a shell to learn what terminal your system believes it's using.

In most cases, Linux auto-detects the terminal type, so you don't need to adjust it. Sometimes, though, this auto-detection doesn't work correctly. In these cases, you may need to set the terminal type manually. If the /etc/termcap file and /usr/share/terminfo directory tree contain appropriate entries, you can do so by setting the TERM environment variable, as shown here:

$ export TERM=vt100

Of course, you should change vt100, if necessary, to whatever value is appropriate. Try browsing through /etc/termcap and the filenames in the /usr/share/terminfo directory to try to find one that matches the terminal or terminal emulator you're using. If you can't find a match, consult the terminal or terminal emulator's documentation; it may support another model's codes. Failing that, the hardware or software may come with an appropriate termcap or terminfo database entry that you can add to your system.

0 0

Post a comment