{
    "mode": "man",
    "parameter": "tput",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/tput/1/json",
    "generated": "2026-08-26T02:33:47Z",
    "synopsis": "tput [-T terminal-type] {cap-code [parameter ...]} ...\ntput [-T terminal-type] [-x] clear\ntput [-T terminal-type] init\ntput [-T terminal-type] reset\ntput [-T terminal-type] longname",
    "sections": {
        "NAME": {
            "content": "tput, init, reset - initialize a terminal, exercise its capabilities, or query terminfo data‐\nbase\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "tput [-T terminal-type] {cap-code [parameter ...]} ...\n\ntput [-T terminal-type] [-x] clear\n\ntput [-T terminal-type] init\n\ntput [-T terminal-type] reset\n\ntput [-T terminal-type] longname\n",
            "subsections": [
                {
                    "name": "tput -S",
                    "content": ""
                },
                {
                    "name": "tput -V",
                    "content": ""
                }
            ]
        },
        "DESCRIPTION": {
            "content": "tput uses the terminfo library and database to make terminal-specific capabilities and infor‐\nmation  available  to the shell, to initialize or reset the terminal, or to report a descrip‐\ntion of the current (or specified) terminal type.  Terminal capabilities are accessed by cap-\ncode.\n\nterminfo(5) discusses terminal capabilities at length and presents a complete  list  of  cap-\ncodes.\n\nWhen retrieving capability values, the result depends upon the capability's type.\n\nBoolean  tput  sets its exit status to 0 if the terminal possesses cap-code, and 1 if it does\nnot.\n\nnumeric  tput writes cap-code's decimal value to the standard output stream if defined (-1 if\nit is not) followed by a newline.\n\nstring   tput writes cap-code's value to the standard output stream  if  defined,  without  a\ntrailing newline.\n\nBefore using a value returned on the standard output, the application should test tput's exit\nstatus to be sure it is 0; see section “EXIT STATUS” below.\n",
            "subsections": [
                {
                    "name": "Operands",
                    "content": "Generally, an operand is a cap-code, a capability code from the terminal database, or a para‐\nmeter  thereto.   Three  others  are specially recognized by tput: init, reset, and longname.\nAlthough these resemble capability codes, they in fact receive special handling; we term them\n“pseudo-capabilities”.\n\ncap-code   indicates a capability from the terminal database.\n\nIf the capability is of string type and takes parameters, the arguments  following\nthe capability will be used as its parameters.\n\nMost  parameters are numeric.  Only a few terminal capabilities require string pa‐\nrameters; tput uses a table to decide which to pass  as  strings.   Normally  tput\nuses  tparm(3NCURSES) to perform the substitution.  If no parameters are given for\nthe capability, tput writes the string without performing the substitution.\n\ninit       initializes the terminal.  If the terminal database is present and  an  entry  for\nthe user's terminal type exists, the following occur.\n\n(1)  tput  retrieves the terminal's mode settings.  It successively tests the file\ndescriptors corresponding to\n\n•   the standard error stream,\n\n•   the standard output stream,\n\n•   the standard input stream, and\n\n•   /dev/tty\n\nto obtain terminal settings.  Having retrieved them, tput remembers which de‐\nscriptor to use for further updates.\n\n(2)  If the terminal dimensions cannot be obtained from the operating system,  but\nthe  environment or terminal type database entry describes them, tput updates\nthe operating system's notion of them.\n\n(3)  tput updates the terminal modes.\n\n•   Any delays specified in the entry (for example, when a newline  is  sent)\nare set in the terminal driver.\n\n•   Tab expansion is turned on or off per the specification in the entry, and\n\n•   if tabs are not expanded, standard tabs (every 8 spaces) are set.\n\n(4)  If  initialization capabilities, detailed in subsection “Tabs and Initializa‐\ntion” of terminfo(5), are present, tput writes them to  the  standard  output\nstream.\n\n(5)  tput flushes the standard output stream.\n\nIf  an  entry lacks the information needed for an activity above, that activity is\nsilently skipped.\n\nreset      re-initializes the terminal.  A reset differs from initialization in two ways.\n\n(1)  tput sets the the terminal modes to a “sane” state,\n\n•   enabling cooked and echo modes,\n\n•   disabling cbreak and raw modes,\n\n•   enabling newline translation, and\n\n•   setting any unset special characters to their default values.\n\n(2)  If any reset capabilities are defined for the terminal type, tput writes them\nto the output stream.  Otherwise, tput uses any defined initialization  capa‐\nbilities.   Reset  capabilities are detailed in subsection “Tabs and Initial‐\nization” of terminfo(5).\n\nlongname   A terminfo entry begins with one or more names by which an application  can  refer\nto  the  entry, before the list of terminal capabilities.  The names are separated\nby “|” characters.  X/Open Curses terms the last name the “long name”,  and  indi‐\ncates that it may include blanks.\n\ntic  warns  if  the last name does not include blanks, to accommodate old terminfo\nentries that treated the long name as an optional feature.  The long name is often\nreferred to as the description field.\n\nIf the terminal database is present and an entry for the user's terminal type  ex‐\nists, tput reports its description to the standard output stream, without a trail‐\ning newline.  See terminfo(5).\n\nNote:  Redirecting the output of “tput init” or “tput reset” to a file will capture only part\nof their actions.  Changes to the terminal modes are not affected by file descriptor redirec‐\ntion, since the terminal modes are altered via ioctl(2).\n"
                },
                {
                    "name": "Aliases",
                    "content": "If tput is invoked via link with any of the names clear, init, or reset, it  operates  as  if\nrun  with the corresponding (pseudo-)capability operand.  For example, executing a link named\nreset that points to tput has the same effect as “tput reset”.   (The  tset(1)  utility  also\ntreats a link named reset specially.)\n\nIf  tput  is  invoked  by a link named init, this has the same effect as “tput init”.  Such a\nlink is seldom employed because another program of that name is in widespread use.\n"
                },
                {
                    "name": "Terminal Size",
                    "content": "Besides the pseudo-capabilities (such as init), tput treats the lines and cols cap-codes spe‐\ncially: it may call setupterm(3NCURSES) to obtain the terminal size.\n\n•   First, tput attempts to obtain these capabilities from the terminal database.  This  gen‐\nerally fails for terminal emulators, which lack a fixed window size and thus omit the ca‐\npabilities.\n\n•   It  then asks the operating system for the terminal's size, which generally works, unless\nthe connection is via a serial line that does not support “NAWS”: negotiations about win‐\ndow size.\n\n•   Finally, it inspects the environment variables LINES and COLUMNS, which may override  the\nterminal size.\n\nIf   the   -T   option   is   given,  tput  ignores  the  environment  variables  by  calling\nusetioctl(TRUE), relying upon the operating system (or, ultimately, the terminal database).\n"
                }
            ]
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-S",
                    "content": "passed to tput from the standard input stream instead of from the command line  (see\nsection  “EXAMPLES”  below).   Only one cap-code is allowed per line.  The -S option\nchanges the meanings of the 0 and 1 exit statuses (see section “EXIT STATUS” below).\n\nSome capabilities use string parameters rather than numeric ones.   tput  employs  a\nbuilt-in  table  and the presence of parameters in its input to decide how to inter‐\npret them, and whether to use tparm(3NCURSES).\n",
                    "flag": "-S"
                },
                {
                    "name": "-T _",
                    "content": "fault  is  taken  from the TERM environment variable.  If specified, the environment\nvariables LINES and COLUMNS are also ignored.\n",
                    "flag": "-T"
                },
                {
                    "name": "-V",
                    "content": "status.\n",
                    "flag": "-V"
                },
                {
                    "name": "-x",
                    "content": "",
                    "flag": "-x"
                }
            ]
        },
        "EXIT STATUS": {
            "content": "Normally, one should interpret tput's exit statuses as follows.\n",
            "subsections": [
                {
                    "name": "Status   Meaning When -S Not Specified",
                    "content": "──────────────────────────────────────────────────────────────────────────────────────────────\n0        Boolean or string capability present\n1        Boolean or numeric capability absent\n2        usage error or no terminal type specified\n3        unrecognized terminal type\n4        unrecognized capability code\n>4       system error (4 + errno)\n\nWhen the -S option is used, some statuses change meanings.\n"
                },
                {
                    "name": "Status   Meaning When -S Specified",
                    "content": "──────────────────────────────────────────────────────────────────────────────────────────────\n0        all operands interpreted\n1        unused\n4        some operands not interpreted\n"
                }
            ]
        },
        "ENVIRONMENT": {
            "content": "tput command reads one environment variable.\n\nTERM    denotes  the terminal type.  Each terminal type is distinct, though many are similar.\nThe -T option overrides its value.\n",
            "subsections": []
        },
        "FILES": {
            "content": "/usr/share/tabset\ntab stop initialization database\n\n/etc/terminfo\ncompiled terminal description database\n",
            "subsections": []
        },
        "PORTABILITY": {
            "content": "Over time ncurses tput has differed from that of System V in two important respects, one  now\nmostly historical.\n\n•   “tput cap-code” writes to the standard output, which need not be a terminal device.  How‐\never, the operands that manipulate terminal modes might not use the standard output.\n\nSystem V  tput's init and reset operands use logic from 4.1cBSD tset, manipulating termi‐\nnal modes.  It checks the same file descriptors (and /dev/tty)  for  association  with  a\nterminal  device as ncurses now does, and if none are, finally assumes a 1200 baud termi‐\nnal.  When updating terminal modes, it ignores errors.\n\nUntil ncurses 6.1 (see section “HISTORY” below), tput did not modify terminal modes.   It\nnow  employs  a  scheme  similar to System V, using functions shared with tset (and ulti‐\nmately based on 4.4BSD tset).  If it is not able to open a terminal (for  instance,  when\nrun by cron(1)), tput exits with an error status.\n\n•   System V  tput  assumes that the type of a cap-code operand is numeric if all the charac‐\nters of its value are decimal numbers; if they are not, it treats cap-code  as  a  string\ncapability.\n\nMost  implementations  that provide support for cap-code operands use the tparm(3NCURSES)\nfunction to expand its parameters.  That function expects a mixture of numeric and string\nparameters, requiring tput to know which type to use.\n\nncurses tput uses a table to determine the parameter  types  for  the  standard  cap-code\noperands, and an internal function to analyze nonstandard cap-code operands.\n\nWhile  more reliable than System V's utility, a portability problem is introduced by this\nanalysis.  An OpenBSD developer adapted the internal library  function  from  ncurses  to\nport  NetBSD's termcap-based tput to terminfo, and modified it to interpret multiple cap-\ncodes (and parameters) on the command line.  Portable applications should not  rely  upon\nthis feature; ncurses offers it to support applications written specifically for OpenBSD.\n\nThis  implementation,  unlike  others, accepts both termcap and terminfo cap-codes if termcap\nsupport is compiled in.  In that case, however, the predefined  termcap  and  terminfo  codes\nhave two ambiguities; ncurses assumes the terminfo code.\n\n•   The  cap-code  dl means deleteline to termcap but parmdeleteline to terminfo.  termcap\nuses the code DL for parmdeleteline.  terminfo uses the code dch1 for deleteline.\n\n•   The cap-code ed means exitdeletemode to termcap but clreos to terminfo.  termcap  uses\nthe code cd for clreos.  terminfo uses the code rmdc for exitdeletemode.\n\nThe  longname operand, -S option, and the parameter-substitution features used in the cup ex‐\nample below, were not supported in AT&T/USL curses before SVr4  (1989).   Later,  4.3BSD-Reno\n(1990)  added  support for longname, and in 1994, NetBSD added support for the parameter-sub‐\nstitution features.\n\nIEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) documents only  the\nclear, init, and reset operands.  A few observations of interest arise from that selection.\n\n•   ncurses  supports  clear  as  it  does any other standard cap-code.  The others (init and\nlongname) do not correspond to terminal capabilities.\n\n•   The tput on SVr4-based systems such as Solaris, IRIX64, and HP-UX, as well as others such\nas AIX and Tru64, also support standard cap-code operands.\n\n•   A few platforms such as FreeBSD recognize termcap names rather than  terminfo  capability\nnames  in their respective tput commands.  Since 2010, NetBSD's tput uses terminfo names.\nBefore that, it (like FreeBSD) recognized termcap names.\n\nBeginning in 2021, FreeBSD uses ncurses tput, configured for both terminfo (tested first)\nand termcap (as a fallback).\n\nBecause (apparently) all certified Unix systems support the full set of capability codes, the\nreason for documenting only a few may not be apparent.\n\n•   X/Open Curses Issue 7 documents tput differently, with cap-code and  the  other  features\nused in this implementation.\n\n•   That  is,  there are two standards for tput: POSIX (a subset) and X/Open Curses (the full\nimplementation).  POSIX documents a subset to avoid the complication of including  X/Open\nCurses and the terminal capability database.\n\n•   While  it  is  certainly possible to write a tput program without using curses, no system\nwith a curses implementation provides a tput utility that does not also support  standard\ncap-codes.\n\nX/Open  Curses  Issue 7 (2009) is the first version to document utilities.  However that part\nof X/Open Curses does not follow existing practice (that is, System V curses behavior).\n\n•   It assigns exit status 4 to “invalid operand”, which may have the same  meaning  as  “un‐\nknown  capability”.  For instance, the source code for Solaris xcurses uses the term “in‐\nvalid” in this case.\n\n•   It assigns exit status 255 to a numeric variable that is not specified  in  the  terminfo\ndatabase.   That likely is a documentation error, mistaking the “-1” written to the stan‐\ndard output to indicate an absent or cancelled numeric capability for an (unsigned)  exit\nstatus.\n\nThe  various  System V  implementations  (AIX,  HP-UX, Solaris) use the same exit statuses as\nncurses.\n\nNetBSD curses documents exit statuses that correspond to neither ncurses nor X/Open Curses.\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "Bill Joy wrote a tput command during development of 4BSD in October 1980.  This initial  ver‐\nsion only cleared the screen, and did not ship with official distributions.\n\nSystem V developed a different tput command.\n\n•   SVr2  (1984)  provided  a rudimentary tput that checked the parameter against each prede‐\nfined capability and returned the corresponding value.  This version of tput did not  use\ntparm(3NCURSES) for parameterized capabilities.\n\n•   SVr3  (1987) replaced that with a more extensive program whose support for init and reset\noperands (more than half the program) incorporated the reset feature of BSD tset  written\nby Eric Allman.\n\n•   SVr4  (1989)  added color initialization by using the origcolors (oc) and origpair (op)\ncapabilities in its init logic.\n\nKeith Bostic refactored BSD tput for shipment in 4.3BSD-Tahoe (1988), then  replaced  it  the\nnext  year  with a new implementation based on System V tput.  Bostic's version similarly ac‐\ncepted some parameters named for terminfo (pseudo-)capabilities: clear, init,  longname,  and\nreset.   However,  because he had only termcap available, it accepted termcap names for other\ncapabilities.  Also, Bostic's BSD tput did not modify the terminal modes as the  earlier  BSD\ntset had done.\n\nAt  the  same  time,  Bostic  added  a shell script named “clear” that used tput to clear the\nscreen.  Both of these appeared in 4.4BSD, becoming the “modern” BSD implementation of tput.\n\nThe origin of ncurses tput lies outside both System V and BSD, in Ross Ridge's mytinfo  pack‐\nage,  published  on  comp.sources.unix in December 1992.  Ridge's program made more sophisti‐\ncated use of the terminal capabilities than the BSD program.  Eric  Raymond  used  that  tput\nprogram  (and  other  parts  of mytinfo) in ncurses in June 1995.  Incorporating the portions\ndealing with terminal capabilities almost without change, Raymond made  improvements  to  the\nway command-line parameters were handled.\n\nBefore ncurses 6.1 (2018), its tset and tput utilities differed.\n\n•   tset was more effective, resetting the terminal modes and special characters.\n\n•   On  the other hand, tset's repertoire of terminal capabilities for resetting the terminal\nwas more limited; it had only equivalents of reset1string  (rs1),  reset2string  (rs2),\nand resetfile (rf), and not the tab stop and margin update features of tput.\n\nThe  reset  program  is  traditionally an alias for tset due to its ability to reset terminal\nmodes and special characters.\n\nAs of ncurses 6.1, the “reset” features of the two programs are (mostly) the same.  Two minor\ndifferences remain.\n\n•   The tset program waits one second when resetting, in case the terminal happens  to  be  a\nhardware device.\n\n•   The two programs write the terminal initialization strings to different streams; that is,\nstandard error for tset and standard output for tput.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "tput init",
                    "content": "Initialize  the  terminal  according  to  the type of terminal in the TERM environment\nvariable.  If the system does not reliably initialize the terminal  upon  login,  this\ncommand  can  be included in $HOME/.profile after exporting the TERM environment vari‐\nable.\n"
                },
                {
                    "name": "tput -T5620 reset",
                    "content": "Reset an AT&T 5620 terminal, overriding the terminal  type  in  the  TERM  environment\nvariable.\n"
                },
                {
                    "name": "tput cnorm",
                    "content": "Set cursor to normal visibility.\n"
                },
                {
                    "name": "tput home",
                    "content": "Move the cursor to row 0, column 0: the upper left corner of the screen, usually known\nas the “home” cursor position.\n"
                },
                {
                    "name": "tput clear",
                    "content": "Clear  the  screen:  write  the clearscreen capability's value to the standard output\nstream.\n"
                },
                {
                    "name": "tput cols",
                    "content": "Report the number of columns used by the current terminal type.\n"
                },
                {
                    "name": "tput -Tadm3a cols",
                    "content": "Report the number of columns used by an ADM-3A terminal.\n"
                },
                {
                    "name": "strong=`tput smso` normal=`tput rmso`",
                    "content": "Set shell variables to capability values: strong and normal, to begin and end, respec‐\ntively, stand-out mode for the terminal.  One might use these to present a prompt.\n\nprintf \"${strong}Username:${normal} \"\n"
                },
                {
                    "name": "tput hc",
                    "content": "Indicate via exit status whether the terminal is a hard copy device.\n"
                },
                {
                    "name": "tput cup 23 4",
                    "content": "Move the cursor to row 23, column 4.\n"
                },
                {
                    "name": "tput cup",
                    "content": "Report the value of the cursoraddress (cup) capability (used  for  cursor  movement),\nwith no parameters substituted.\n"
                },
                {
                    "name": "tput longname",
                    "content": "Report  the terminfo database's description of the terminal type specified in the TERM\nenvironment variable.\n"
                },
                {
                    "name": "tput -S",
                    "content": "Process multiple capabilities.  The -S option can be  profitably  used  with  a  shell\n“here document”.\n\n$ tput -S <<!\n> clear\n> cup 10 10\n> bold\n> !\n\nThe  foregoing  clears  the screen, moves the cursor to position (10, 10) and turns on\nbold (extra bright) mode.\n"
                },
                {
                    "name": "tput clear cup 10 10 bold",
                    "content": "Perform the same actions as the foregoing “tput -S” example.\n"
                }
            ]
        },
        "SEE ALSO": {
            "content": "clear(1), stty(1), tabs(1), tset(1), termcap(3NCURSES), terminfo(5)\n\nncurses 6.4                                  2024-01-13                                      tput(1)",
            "subsections": []
        }
    },
    "summary": "tput, init, reset - initialize a terminal, exercise its capabilities, or query terminfo data‐ base",
    "flags": [
        {
            "flag": "-S",
            "long": null,
            "arg": null,
            "description": "passed to tput from the standard input stream instead of from the command line (see section “EXAMPLES” below). Only one cap-code is allowed per line. The -S option changes the meanings of the 0 and 1 exit statuses (see section “EXIT STATUS” below). Some capabilities use string parameters rather than numeric ones. tput employs a built-in table and the presence of parameters in its input to decide how to inter‐ pret them, and whether to use tparm(3NCURSES)."
        },
        {
            "flag": "-T",
            "long": null,
            "arg": null,
            "description": "fault is taken from the TERM environment variable. If specified, the environment variables LINES and COLUMNS are also ignored."
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": "status."
        },
        {
            "flag": "-x",
            "long": null,
            "arg": null,
            "description": ""
        }
    ],
    "examples": [
        "Initialize  the  terminal  according  to  the type of terminal in the TERM environment",
        "variable.  If the system does not reliably initialize the terminal  upon  login,  this",
        "command  can  be included in $HOME/.profile after exporting the TERM environment vari‐",
        "able.",
        "Reset an AT&T 5620 terminal, overriding the terminal  type  in  the  TERM  environment",
        "variable.",
        "Set cursor to normal visibility.",
        "Move the cursor to row 0, column 0: the upper left corner of the screen, usually known",
        "as the “home” cursor position.",
        "Clear  the  screen:  write  the clearscreen capability's value to the standard output",
        "stream.",
        "Report the number of columns used by the current terminal type.",
        "Report the number of columns used by an ADM-3A terminal.",
        "Set shell variables to capability values: strong and normal, to begin and end, respec‐",
        "tively, stand-out mode for the terminal.  One might use these to present a prompt.",
        "printf \"${strong}Username:${normal} \"",
        "Indicate via exit status whether the terminal is a hard copy device.",
        "Move the cursor to row 23, column 4.",
        "Report the value of the cursoraddress (cup) capability (used  for  cursor  movement),",
        "with no parameters substituted.",
        "Report  the terminfo database's description of the terminal type specified in the TERM",
        "environment variable.",
        "Process multiple capabilities.  The -S option can be  profitably  used  with  a  shell",
        "“here document”.",
        "$ tput -S <<!",
        "> clear",
        "> cup 10 10",
        "> bold",
        "> !",
        "The  foregoing  clears  the screen, moves the cursor to position (10, 10) and turns on",
        "bold (extra bright) mode.",
        "Perform the same actions as the foregoing “tput -S” example."
    ],
    "see_also": [
        {
            "name": "clear",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/clear/1/json"
        },
        {
            "name": "stty",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/stty/1/json"
        },
        {
            "name": "tabs",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/tabs/1/json"
        },
        {
            "name": "tset",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/tset/1/json"
        },
        {
            "name": "termcap",
            "section": "3NCURSES",
            "url": "https://www.chedong.com/phpMan.php/man/termcap/3NCURSES/json"
        },
        {
            "name": "terminfo",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/terminfo/5/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "View and modify terminal settings and capabilities.",
        "examples": [
            {
                "description": "Move the cursor to a screen location",
                "command": "tput cup {{row}} {{column}}"
            },
            {
                "description": "Set foreground (af) or background (ab) color",
                "command": "tput {{setaf|setab}} {{ansi_color_code}}"
            },
            {
                "description": "Reverse text and background colors",
                "command": "tput rev"
            },
            {
                "description": "Reset all terminal text attributes",
                "command": "tput sgr0"
            },
            {
                "description": "Show number of columns, lines, or colors",
                "command": "tput {{cols|lines|colors}}"
            },
            {
                "description": "Enable or disable word wrap",
                "command": "tput {{smam|rmam}}"
            },
            {
                "description": "Hide or show the terminal cursor",
                "command": "tput {{civis|cnorm}}"
            },
            {
                "description": "Save or restore terminal text status (smcup also captures scroll wheel events)",
                "command": "tput {{smcup|rmcup}}"
            }
        ]
    }
}