This command is only helpful for users accessing the POSIX shellvia rlogin.
You can use tput to
indicate one capability of a terminal (Format 1)
list a number of capabilities of a terminal (Format 2)
initialize a terminal (Format 3)
reset a terminal (Format 4)
display the long name of a terminal (Format 5)
clear the screen (Format 6).
Syntax
Format 1: |
tput[ -T typ] capname[ parameter...] |
Format 2: |
tput -S
|
Format 3: |
tput[ -T typ] init
|
Format 4: |
tput[ -T typ] reset
|
Format 5: |
tput[ -T typ] longname
|
Format 6: |
tput[ -T typ] clear
|
Indicating one capability of a terminal
tput indicates capabilities of a terminal as defined in the terminfo database.
type indicates the type of terminal whose capabilities are to be queried. If the -T -T
(capability name) capname is the alias (abbreviated form) of a terminal capability as defined in the terminfo source file. To find out whether your terminal has a particular capability (attribute), you specify the appropriate alias capname. Depending on the type of attribute, tput responds as follows:
If capname is an attribute for which no value is assigned to the specified terminal type in the terminfo database, tput returns -1.
If the capname attribute is a string that takes parameters, you can enter the parameters in parameter. capname and parameter are passed to tput as a compound string. An all numeric parameter is passed as a number. |
Listing a number of capabilities of a terminal
tput can be used to list multiple capabilities of the user’s terminal. You pass the capabilities from standard input rather than from the command line (see Example 4). Only one terminal capability is permitted per line. If the -T
(capability name) capname is the alias (abbreviated form) of a terminal capability as defined in the terminfo source file. To find out whether your terminal has a particular capability (attribute), you specify the appropriate alias capname. Depending on the type of attribute, tput responds as follows:
If capname is an attribute for which no value is assigned to the specified terminal type in the terminfo database, tput returns -1.
If the capname attribute is a string that takes parameters, you can enter the parameters in parameter. capname and parameter are passed to tput as a compound string. An all numeric parameter is passed as a number. |
Initializing a terminal
If the terminfo database contains an entry for the user’s terminal, tput initializes the terminal in accordance with the terminal type specified in -T
If the terminfo entry does not contain the information needed for any of these activities, that activity is silently skipped.
This indicates the type of terminal whose capabilities you want to use to initialize your terminal. -T |
Resetting a terminal
tput outputs the terminal’s reset strings (capname rs1, rs2, rs2, rf). If the reset strings are not present but initialization strings are, the initialization strings are output. Otherwise, reset behaves identically to init.
This indicates the type of terminal whose capabilities you want to use to reset your terminal. -T |
Displaying the long name of a terminal
If the terminfo database is present and contains an entry for the user’s terminal (see Format 1, -T |
Clearing the screen
tput outputs the clear-screen sequence.
This indicates the type of terminal whose capabilities you want to use to reset your terminal. -T |
Exit status
When capname is of type boolean and the -S option is not set:
When capname is of type string and the -S option is not set:
When capname is of type boolean or string and the -S option is set:
When capname is of type integer:
Error situations are indicated by an exit status of 2, 3 or 4. |
Error
Depending on the exit status, tput issues one of the following error messages:
terminal type type unknown or no terminfo database present, exit status 3
Self-explanatory, exit status 4 |
Variable
TERM Default value used for the type of terminal when -T |
File
/usr/share/lib/terminfo/?/* Directory containing binary versions of the terminal type descriptions. /usr/include/curses.h curses() header file /usr/include/term.h terminfo() header file /usr/lib/tabset/* Information on tab handling |
Locale
The following environment variables affect the execution 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
Initializing a terminal
A sequence of control characters that initializes the screen is passed to the user’s terminal. The sequence used is the one appropriate to the terminal type defined in the TERM environment variable. |
Example 2
Displaying the number of columns for the current terminal:
|
Example 3
Indicating whether the current terminal is a hardcopy terminal:
Since hc is a Boolean type value, tput simply returns an exit status, which you can inspect with echo $?. The returned value of 1 indicates that the terminal is not a hardcopy terminal. |
Example 4
Displaying several capabilities in one tput invocation
The screen is cleared, the cursor moved to position 10,10 and bold (extra bright) mode turned on. The list is terminated by here in the last line. |
Example 5
The file input has the following contents: cols lines Using this file as input to tput for terminals of types 97801 and 97808 would, for example, produce the following result:
|
See also
stty, tabs |