OpenBSD manual page server

Manual Page Search Parameters

TPUT(1) General Commands Manual TPUT(1)

tput, clearterminal capability interface

tput [-T term] attribute [attribute-arg ...] ...

tput [-T term] -S

clear [-T term]

The tput utility makes terminal-dependent information available to users or shell applications. When invoked as clear, it provides the same functionality as tput clear.

The options are as follows:

The attributes are read from stdin instead of the command line.
The terminal name as found in the terminfo(5) database; for example, “vt100” or “xterm”. If not specified, tput retrieves the TERM variable from the environment.

tput outputs a string if the attribute is of type string or a number if it is of type integer. If the attribute is of type boolean, tput exits 0 if the terminal has the capability or 1 if it does not. Each attribute should be a string defined in either terminfo(5) or termcap(5).

If the attribute is of type string and takes arguments (e.g., cursor movement, the terminfo(5) “cup” sequence) the arguments are taken from the command line immediately following the attribute.

The following special attributes are available:

Clear the screen (the terminfo(5) “clear” sequence).
Print the terminfo(5) initialization strings for the specified terminal.
Print the descriptive name of the user's terminal type.
Reset the terminal (using the terminfo(5) reset sequences).

Determine the terminal type.

The exit value of tput is based on the last attribute specified. If the attribute is of type string or of type integer, the exit value is as follows:

The requested string was written successfully.
Usage error.
Unknown terminal type.
Unknown attribute name.
An error occurred.

If the attribute is of type boolean, tput exits with a value of 0 if the terminal has this attribute or 1 if it does not.

Clear the screen and go to line 5 column 10:

$ tput clear cup 5 10

Go to line 6 column 11 and delete 6 characters:

$ tput cup 6 11 dch 6

terminfo(3), terminfo(5)

The tput utility is compliant with the IEEE Std 1003.1-2008 (“POSIX.1”) specification.

The flag [-S] and the attribute longname are extensions to that specification.

The clear utility first appeared in 2BSD. The tput utility first appeared in AT&T System V Release 2 UNIX and was reimplemented for 4.3BSD-Reno.

tput can't really distinguish between different types of attributes.

December 22, 2022 OpenBSD-current