This command is only useful if access to the POSIX shell is via ssh or rlogin from a character terminal.
You can use tput to
output one capability of a terminal (Format 1)
output multiple capabilities of a terminal (Format 2)
initialize a terminal (Format 3)
reset a terminal (Format 4)
output the long name of a terminal type (Format 5)
clear the screen (Format 6).
Syntax
| Format 1: |
tput[ -T type] capname[ parameter...] |
| Format 2: |
tput[ -T type] -S
|
| Format 3: |
tput[ -T type] init
|
| Format 4: |
tput[ -T type] reset
|
| Format 5: |
tput[ -T type] longname
|
| Format 6: |
tput[ -T type] clear
|
Output one capability of a terminal
One capability of a terminal is output. These capabilities are defined in the terminfo database. Depending on the type of capability, tput outputs the following:
The "Terminal capabilities" section of the "POSIX Commands" manual provides an overview of the capabilities of the "xterm" terminal type and the corresponding terminfo names (see column "terminfo name").
type specifies the type of terminal whose capability should be output. -T
(capability name) capname is the short name of a terminal capability, as shown in the terminfo name column in the "Terminal capabilities" section of the "POSIX Commands" manual. To output a particular terminal capability, the corresponding short name capname must be specified.
If the capname capability is a string which takes parameters, then these parameters are specified after capname. |
Output of multiple capabilities of a terminal
This format of tput can output multiple properties of the terminal. The short names of the capabilities and, if applicable, the parameters are read from standard input. Only one capability may be specified per input line. If the standard input is read from the terminal, the input must be terminated with CTRL+D. The input lines have the format:
See Format 1. |
Initializing a terminal
If the terminfo database contains an entry for the terminal type, tput initializes the terminal accordingly by performing the following steps:
If the terminfo entry does not contain the information for one of the steps, this step is skipped without an error message.
See Format 1. |
Resetting a terminal
If the terminfo database contains an entry for the terminal type, tput outputs the strings for resetting the terminal. The short names of these capabilities are rs1, rs2, rs3 and rf. If no strings are defined for resetting, but there are for initialization, the initialization strings are output.
See Format 1. |
Output the long name of a terminal type
If the terminfo database contains an entry for the terminal type, tput outputs the long name of the terminal type.
See Format 1. |
Clear the screen
If the terminfo database contains an entry for the terminal type, tput outputs the clear-screen control character sequence.
See Format 1. |
Exit status
Capability of type boolean:
Capability of type string:
Capability of type integer:
Format 2 (tput -S):
Error situations:
|
Error
Depending on the exit status, tput issues one of the following error messages:
| ||||
Variable
TERM Default value used for the type of terminal when -T |
File
/etc/termcap File with all properties of all terminals in readable format. /usr/share/lib/terminfo/?/* Files with all properties of one terminal each in binary (compiled) format. |
Locale
The following environment variables affect the message output of tput: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
Emit an acoustic signal
The terminal emits an acoustic signal. Depending on the terminal's settings, a visual signal may also be emitted, or no signal at all. |
Example 2
Output the number of columns of the current terminal
The terminal has (currently) 80 columns. |
Example 3
Check whether the current terminal is a hardcopy terminal
Since hc is a Boolean value, tput only returns an exit status. This exit status is queried with echo $?. The exit status is 1, so the current terminal is not a hardcopy terminal. |
Example 4
Output of multiple terminal properties with one tput call The file geom has the following contents: cols lines
The terminal has 120 columns (capability cols) and 42 lines (capability lines). |
Example 5
Output of text in an alternative display mode
Output of the smul capability turns underlined mode on, and output of the rmul capability turns it off. |
See also
stty, tabs |