6.5. Other tput Functionality

tput can do many things. You have seen it used for colours and moving the cursor. This section includes some of the functions that may be useful in writing prompts. man tput doesn't go into much detail about the available commands, but Emilio Lopes e-mailed me to point out that man terminfo will give you a huge list of capabilities, many of which are device independent, and therefore better than the ANSI escape sequences previously mentioned.

tput Colour Capabilities

tput setab [1-7]

Set a background colour using ANSI escape

tput setb [1-7]

Set a background colour

tput setaf [1-7]

Set a foreground colour using ANSI escape

tput setf [1-7]

Set a foreground colour

tput Text Mode Capabilities

tput bold

Set bold mode

tput dim

turn on half-bright mode

tput smul

begin underline mode

tput rmul

exit underline mode

tput rev

Turn on reverse mode

tput smso

Enter standout mode (bold on rxvt)

tput rmso

Exit standout mode

tput sgr0

Turn off all attributes (doesn't work quite as expected)

tput Clear and Insert Capabilities

tput ech N

Erase N characters

tput clear

clear screen and home cursor

tput el1

Clear to beginning of line

tput el

clear to end of line

tput ed

clear to end of screen

tput ich N

insert N characters (moves rest of line forward!)

tput il N

insert N lines

This is by no means a complete list of what terminfo and tput allow, in fact it's only the beginning. man tput and man terminfo if you want to know more.