{{Short description|Standard Unix operating system command}} {{lowercase}} {{Infobox software | name = tput | logo = | screenshot = | screenshot size = | caption = | author = | developer = | released = {{Start date and age|1980s}} | latest release version = | latest release date = | operating system = Unix and Unix-like | platform = Cross-platform | genre = Command | license = | website = }} In computing, '''<code>tput</code>''' is a standard Unix operating system command which makes use of terminal capabilities.

Depending on the system, <code>tput</code> uses the terminfo or termcap database, as well as looking into the environment for the terminal type.

==History== <code>tput</code> was provided in UNIX System V in the early 1980s. A clone of the AT&T <code>tput</code> was submitted to volume 7 of the '''mod.sources''' newsgroup (later '''comp.sources.unix''') in September 1986.<ref>{{cite web |url=https://groups.google.com/forum/embed/#!topic/mod.sources/G1VegA0Aa_w |title=Public-domain tput(1) program |first=Badri |last=Lokanathan |date=1986-08-28 |access-date=2008-04-22 }}</ref><ref>{{cite web |url=https://groups.google.com/forum/embed/#!topic/mod.sources/Eq3EPGxuYrI |title=Public-domain TPUT (corrected implementation) |first=Badri |last=Lokanathan |date=1986-09-19 |access-date=2008-04-22 }}</ref> In contrast to the System V program, the clone used termcap rather than terminfo. It accepted command-line parameters for the <code>cm</code> (cursor addressing) capability, and recognized terminfo capability names.

System V Release 3 provided an improved version which combined the different initialization capabilities as a new option <code>init</code>, and the reset capabilities as <code>reset</code>, thereby simplifying use of <code>tput</code> for initializing or reinitializing the terminal.<ref>{{Cite book |url=https://books.google.com/books?id=GsUMLqtYI1UC&q=tput |title=Termcap and terminfo |last1=Strang |first1=John |last2=Mui |first2=Linda |last3=O'Reilly |first3=Tim |publisher=O'Reilly |year=1988 |page=[https://books.google.com/books?id=GsUMLqtYI1UC&pg=PA56 56–57] |isbn=0-937175-22-6 |archive-date=2026-01-02 |access-date=2026-02-03 |archive-url=https://web.archive.org/web/20260102013025/https://books.google.com/books?q=tput&id=GsUMLqtYI1UC |url-status=live }}</ref> System V Release 3.2 added several printer-specific capabilities to the terminfo database, such as <code>swidm</code> (enter_doublewide_mode) which <code>tput</code> could use. It also added capabilities for color.<!-- also modem control, windowing which are seldom used. The capabilities were added in the "same" order as they appear in the term.h header file in various implementations, the tput2 file gives a good reference point for SVR3.0, which ends at smgr -->

System V Release 4 defined additional terminfo capabilities including standardized ANSI color capabilities <code>setaf</code> and <code>setab</code>, which could be used by <code>tput</code>.

BSD platforms provided a different implementation of <code>tput</code> in 4.3BSD-Reno (June 1990).<ref>{{cite web |url=http://minnie.tuhs.org/Unix_History/4bsd |title=3BSD/4BSD versions |date=2000-06-25 |publisher=The Unix Heritage Society |access-date=2008-04-20 }}</ref> It used termcap, recognizing only termcap capability names, and did not accept command-line parameters for cursor-addressing. FreeBSD used this in 1994, improving it by accepting one or two numeric command-line parameters.<ref>{{cite web |url=http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/tput/tput.c |title=CVS log for src/usr.bin/tput/tput.c |date=May 27, 1994 }}</ref>

Ross Ridge's '''mytinfo''' package in 1992<ref>{{cite newsgroup |url=https://groups.google.com/forum/#!topic/comp.sources.unix/tC8cAf6ZHjM |author=Ross Ridge |title=mytinfo - a replacement for terminfo and termcap |newsgroup=comp.sources.unix |date=December 27, 1992 |access-date=February 3, 2026 |archive-date=September 15, 2025 |archive-url=https://web.archive.org/web/20250915161221/https://groups.google.com/forum/#!topic/comp.sources.unix/tC8cAf6ZHjM |url-status=live }}</ref> provided a <code>tput</code> which accepted either termcap or terminfo capability names. Like the Reno implementation, it did not pass command-line arguments to parameterized capabilities. ncurses incorporated the '''mytinfo''' code in June 1995. The initial version added a <code>-S</code> option, and interpreted command-line parameters as described in the System V Release 4 documentation.

==Portability== The Open Group defines one option (<code>-T</code>, to specify the terminal type) and three keywords (<code>init</code>, <code>clear</code> and <code>reset</code>). Most implementations accept the name of a terminal capability together with any parameters that may be needed for that. However, some implementations expect a termcap name, while others expect a terminfo name.

All System V Release 4 implementations, as well as those which are designed to be compatible, also recognize a <code>-S</code> option (to tell <code>tput</code> to read data from the standard input), and an additional keyword <code>longname</code>. They also accept command-line parameters, usually distinguishing numeric from string parameters by the form of the parameter, checking for all-numeric characters. That makes it impossible for example to set a function-key label to a string of digits. Using a different approach, ncurses determines the expected type of the parameters with a table of the terminfo capabilities which use string parameters, eliminating the ambiguity.

==See also== * List of Unix commands

==References== {{Reflist}}

==Further reading== * {{cite book| title=Linux and UNIX shell programming| series=Safari Tech Books Online| chapter=Creating screen output| first=D. S. W.| last=Tansley| publisher=Addison-Wesley| year=2000| isbn=978-0-201-67472-9| url-access=registration| url=https://archive.org/details/linuxunixshellpr00davi}}

==External links== {{Wikibooks|Guide to Unix|Commands}} * {{man|cu|tput|SUS}} * {{man|1|tput|Linux}} * [http://invisible-island.net/ncurses/man/tput.1.html ''tput(1)'' manual page for ncurses] * [http://www.ibm.com/support/knowledgecenter/en/ssw_aix_61/com.ibm.aix.cmds5/tput.htm AIX] * {{webarchive |url=https://web.archive.org/web/20130513061455/http://www.tenacitymedia.com/cgi-bin/bsdi-man?proto=1.1&query=tput&msection=1&apropos=0 |date=May 13, 2013 |title=BSDI }} * [http://uw714doc.sco.com/en/man/html.1/tput.1.html SCO] * {{webarchive |url= https://web.archive.org/web/20160304022957/http://h20565.www2.hpe.com/hpsc/doc/public/display?docId=emr_na-c02273396 |date=Mar 4, 2016 |title=HPUX }} * [http://techpubs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?coll=0650&db=man&fname=/usr/share/catman/u_man/cat1/tput.z SGI] * [http://docs.oracle.com/cd/E23824_01/html/821-1461/tput-1.html Sun] * {{webarchive |url=https://web.archive.org/web/20120207000157/http://h30097.www3.hp.com/docs/base_doc/DOCUMENTATION/V51_HTML/MAN/MAN1/0386____.HTM |date=February 7, 2012 |title=Tru64 }} * [http://tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html ''Colours and Cursor Movement With tput'' in Bash Prompt HOWTO] * [http://www.ibm.com/developerworks/aix/library/au-learningtput/?S_TACT=105AGY06& ''Discover tput'' on IBM DeveloperWorks]

{{Unix commands}}

Category:Unix SUS2008 utilities Category:Text mode