tset
Initialize terminal characteristics
SYNOPSIS
tset [options] [terminal_type]
PARAMETERS
-s
Output the shell commands to set and export the TERM environment variable. This is commonly used with eval to update the current shell's environment.
-Q
Suppress printing of "Erase is char" and "Kill is char" messages to standard error.
-I
Suppress all output, including terminal initialization strings and environment variable settings. Only actions like setting erase/kill characters are performed.
-m mapping
Specify a terminal type mapping. This allows tset to select a terminal type based on a pattern matching the port type (e.g., dialup:vt100 or ?:ansi).
-d type
Specify a default terminal type to use if tset cannot determine the terminal type automatically based on the environment or port settings.
-q
Query the terminal type and print it to standard output. No terminal initialization is performed, and no environment variables are set.
-c
Check the terminfo (or termcap) database for the number of columns and update the terminal settings if necessary, especially useful for window resizing.
-r
Report the determined terminal type to standard error before performing any initialization. Useful for debugging.
-e [char]
Set the erase character. If char is omitted, it defaults to Backspace. Use special notation for control characters (e.g., ^H for Backspace).
-k [char]
Set the kill character. If char is omitted, it defaults to Ctrl-U. Similar to -e, special notation can be used.
-i [char]
Set the interrupt character. If char is omitted, it defaults to Ctrl-C. Similar to -e, special notation can be used.
terminal_type
A specific terminal type to explicitly set. If provided, tset will use this type instead of attempting to determine it automatically.
DESCRIPTION
The tset command is used to initialize the terminal, often during login, to ensure applications display correctly. It determines the terminal type and sets various terminal characteristics, such as the erase, kill, and interrupt characters, as well as the window size. It relies on the terminfo (or termcap) database to retrieve the necessary terminal capabilities. While still functional, tset has largely been superseded by the more modern and flexible tput init command for setting up terminal modes and capabilities. Despite this, it remains a common sight in older shell initialization scripts, like .profile or .login, where it helps adapt the terminal to the specific display environment, handling cases like dialing up from a different terminal type.
CAVEATS
The tset command is part of the ncurses library, which primarily uses the terminfo database but provides termcap compatibility. It is largely considered a legacy command, with its functionality mostly absorbed and improved upon by the tput utility, specifically tput init and tput reset. New shell scripts should generally prefer tput for terminal initialization.
COMMON USAGE WITH <B>EVAL</B>
A common idiom for tset is to use it with eval to set the TERM environment variable correctly. For example, eval `tset -s vt100` would output commands like TERM=vt100; and export TERM;, which eval then executes in the current shell.
While tset can automatically determine the terminal type based on port settings or environment variables (like TERM or TERMCAP), explicitly providing a terminal_type or using the -d option provides robustness in environments where auto-detection might fail.
HISTORY
The tset utility originated in the early days of Unix, designed to initialize character-mode terminals based on the termcap database. Its primary role was to set up the correct terminal type and characteristics for various display devices connected to a system. As the terminfo database superseded termcap, tset evolved to work with terminfo (often through compatibility layers). Over time, much of tset's functionality, particularly regarding terminal initialization strings, was integrated into the more versatile tput command, making tset less critical for modern shell environments, though it remains available for backward compatibility and in older scripts.