- Move the cursor to a screen location:tput cup [y_coordinate] [x_coordinate]- Set foreground (af) or background (ab) color:tput [setaf|setab] [ansi_color_code]- Show number of columns, lines, or colors:tput [cols|lines|colors]- Ring the terminal bell:tput bel- Reset all terminal attributes:tput sgr0- Enable / Disable word wrap:tput [smam|rmam]
tput [-Ttype] capname [parameters] tput [-Ttype] init tput [-Ttype] reset tput [-Ttype] longname tput -S << tput -V
The tput utility uses the terminfo database to make the values of terminal-dependent capabilities and information available to the shell (see sh(1)), to initialize or reset the terminal, or return the long name of the requested terminal type. The result depends upon the capability's type:
Before using a value returned on the standard output, the application should test the exit code (e.g., $?, see sh(1)) to be sure it is 0. (See the EXIT CODES and DIAGNOSTICS sections.) For a complete list of capabilities and the capname associated with each, see terminfo(5).
If tput is invoked by a link named reset, this has the same effect as tput reset. The tset(1) utility also treats a link named reset specially:
If tput is invoked by a link named init, this has the same effect as tput init. Again, you are less likely to use that link because another program named init has a more well-established use.
If the -S option is used, tput checks for errors from each line, and if any errors are found, will set the exit code to 4 plus the number of lines with errors. If no errors are found, the exit code is 0. No indication of which line failed can be given so exit code 1 will never appear. Exit codes 2, 3, and 4 retain their usual interpretation. If the -S option is not used, the exit code depends on the type of capname:
Any other exit code indicates an error; see the DIAGNOSTICS section.
tput prints the following error messages and sets the corresponding exit codes.
The longname and -S options, and the parameter-substitution features used in the cup example, are not supported in BSD curses or in AT&T/USL curses before SVr4.
IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) documents only the operands for clear, init and reset. There are a few interesting observations to make regarding that:
Because (apparently) all of the certified Unix systems support the full set of capability names, the reasoning for documenting only a few may not be apparent.
Most implementations which provide support for capname operands use the tparm function to expand parameters in it. That function expects a mixture of numeric and string parameters, requiring tput to know which type to use. This implementation uses a table to determine that for the standard capname operands, and an internal library function to analyze nonstandard capname operands. Other implementations may simply guess that an operand containing only digits is intended to be a number.
clear(1), stty(1), tabs(1), tset(1), terminfo(5), termcap(3NCURSES).
This describes ncurses version 6.0 (patch 20160625).