is a powerful tool to use if you often log in at different terminals. You can use tset to prompt you with a default terminal type, giving you the opportunity to specify a new terminal type when you log in:
TERM = (vt100)
A problem with tset , however, is that it requires you to know your terminal type. You might log in at a new terminal and have no idea what to set the terminal type to. Or your terminal might be configured to emulate another terminal type, without your knowledge. New users in particular tend to be confused by the tset prompt.
or in .profile :
The advantage of qterm is that it sets the terminal type without your intervention. You don't need to know what your terminal type is, it just gets set automatically.
qterm works by sending the terminal a query string and returning the terminal type depending on the terminal's response. qterm is configured using a listing of responses and the terminals they correspond to. By default, qterm looks for the listings in a systemwide location, such as /usr/usc/lib/qtermtab or /usr/local/lib/qtermtab . In addition, you can call qterm with the +usrtab option, so that it will look for a file called .qtermtab in your home directory.
# # QtermTab - Query terminal table for qterm. # #SendStr ReceiveStr TermName FullTermName # ^[Z ^[[?1;0c vt100 Base vt100 ^[Z ^[[?1;1c vt100 vt100 with STP ^[Z ^[[?1;2c vt100 ANSI/VT100 Clone ... ^[Z ^[/K h29 Zenith z29 in zenith mode ^[Z ^[/Z vt52 Generic vt52 ^[Z ^[[0n vt100 AT&T UNIX PC 7300
If your terminal isn't listed here, you can just add it. To find out your terminal's response to the query string, just echo ESC Z to your terminal and see what the response is. For example, I logged in from my Macintosh terminal emulator at home and found that qterm didn't recognize my terminal type:
qterm defaults to the right terminal description, but I'd still rather define my own entry. I find out my terminal's response to the ESC Z string:
(Note that ESC prints as
^[Z ^[[E;Y| vt100 Macintosh terminal emulator
Now when I run qterm , the terminal is recognized:
the TERM variable is set correctly:
Now for the caveat: qterm 's results are only as accurate as the qtermtab file. Not all terminals respond to the ESC Z string, and you may not be able to find a string that it does respond uniquely to. And some terminals do uncanny imitations of others. For example, I'm currently using anwindow, but qterm thinks I'm using a vt100 :
#^[Z ^[[?1;2c vt100 ANSI/VT100 Clone ^[Z ^[[?1;2c xterm xterm window
And then call qterm with the +usrtab command-line option:
setenv TERM `qterm +usrtab`