1tput(1)                     General Commands Manual                    tput(1)
2
3
4

NAME

6       tput, reset - initialize a terminal or query terminfo database
7

SYNOPSIS

9       tput [-Ttype] capname [parms ... ]
10       tput [-Ttype] init
11       tput [-Ttype] reset
12       tput [-Ttype] longname
13       tput -S  <<
14       tput -V
15

DESCRIPTION

17       The  tput utility uses the terminfo database to make the values of ter‐
18       minal-dependent capabilities and information  available  to  the  shell
19       (see  sh(1)),  to  initialize or reset the terminal, or return the long
20       name of the requested terminal type.  The result depends upon the capa‐
21       bility's type:
22
23              string
24                   tput writes the string to the standard output.  No trailing
25                   newline is supplied.
26
27              integer
28                   tput writes the decimal value to the standard output,  with
29                   a trailing newline.
30
31              boolean
32                   tput  simply sets the exit code (0 for TRUE if the terminal
33                   has the capability, 1 for FALSE if it does not), and writes
34                   nothing to the standard output.
35
36       Before  using  a value returned on the standard output, the application
37       should test the exit code (e.g., $?, see sh(1)) to be  sure  it  is  0.
38       (See  the EXIT CODES and DIAGNOSTICS sections.)  For a complete list of
39       capabilities and the capname associated with each, see terminfo(5).
40
41       -Ttype indicates the type of terminal.  Normally this option is  unnec‐
42              essary,  because the default is taken from the environment vari‐
43              able TERM.  If -T is specified, then the shell  variables  LINES
44              and COLUMNS will also be ignored.
45
46       capname
47              indicates the capability from the terminfo database.  When term‐
48              cap support is compiled in, the termcap name for the  capability
49              is also accepted.
50
51       parms  If  the  capability is a string that takes parameters, the argu‐
52              ments parms will be instantiated into the string.
53
54              Most parameters are numbers.  Only a few  terminfo  capabilities
55              require  string parameters; tput uses a table to decide which to
56              pass as strings.  Normally tput uses tparm (3X) to  perform  the
57              substitution.   If  no  parameters are given for the capability,
58              tput writes the string without performing the substitution.
59
60       -S     allows more than one capability per  invocation  of  tput.   The
61              capabilities  must  be  passed  to  tput from the standard input
62              instead of from the command line (see example).  Only  one  cap‐
63              name  is allowed per line.  The -S option changes the meaning of
64              the 0 and 1 boolean and string exit codes (see  the  EXIT  CODES
65              section).
66
67              Again,  tput  uses a table and the presence of parameters in its
68              input to decide whether to use tparm (3X), and how to  interpret
69              the parameters.
70
71       -V     reports  the  version of ncurses which was used in this program,
72              and exits.
73
74       init   If the terminfo database is present and an entry for the  user's
75              terminal exists (see -Ttype, above), the following will occur:
76
77              (1)    if present, the terminal's initialization strings will be
78                     output as detailed in the terminfo(5) section on Tabs and
79                     Initialization,
80
81              (2)    any delays (e.g., newline) specified in the entry will be
82                     set in the tty driver,
83
84              (3)    tabs expansion will be turned on or off according to  the
85                     specification in the entry, and
86
87              (4)    if  tabs  are  not  expanded,  standard  tabs will be set
88                     (every 8 spaces).
89
90              If an entry does not contain the information needed for  any  of
91              the  four  above  activities,  that  activity  will  silently be
92              skipped.
93
94       reset  Instead of putting out initialization  strings,  the  terminal's
95              reset strings will be output if present (rs1, rs2, rs3, rf).  If
96              the reset strings are not present,  but  initialization  strings
97              are,  the  initialization  strings  will  be output.  Otherwise,
98              reset acts identically to init.
99
100       longname
101              If the terminfo database is present and an entry for the  user's
102              terminal  exists  (see  -Ttype above), then the long name of the
103              terminal will be put out.  The long name is the last name in the
104              first  line  of the terminal's description in the terminfo data‐
105              base [see term(5)].
106
107       If tput is invoked by a link named reset, this has the same  effect  as
108       tput reset.  See tset for comparison, which has similar behavior.
109

EXAMPLES

111       tput init
112            Initialize  the  terminal according to the type of terminal in the
113            environmental variable TERM.  This command should be  included  in
114            everyone's .profile after the environmental variable TERM has been
115            exported, as illustrated on the profile(5) manual page.
116
117       tput -T5620 reset
118            Reset an AT&T 5620 terminal, overriding the type  of  terminal  in
119            the environmental variable TERM.
120
121       tput cup 0 0
122            Send the sequence to move the cursor to row 0, column 0 (the upper
123            left corner of the screen, usually  known  as  the  "home"  cursor
124            position).
125
126       tput clear
127            Echo the clear-screen sequence for the current terminal.
128
129       tput cols
130            Print the number of columns for the current terminal.
131
132       tput -T450 cols
133            Print the number of columns for the 450 terminal.
134
135       bold=`tput smso` offbold=`tput rmso`
136            Set  the  shell  variables bold, to begin stand-out mode sequence,
137            and offbold, to end standout mode sequence, for the current termi‐
138            nal.  This might be followed by a prompt: echo "${bold}Please type
139            in your name: ${offbold}\c"
140
141       tput hc
142            Set exit code to indicate if the current terminal is a  hard  copy
143            terminal.
144
145       tput cup 23 4
146            Send the sequence to move the cursor to row 23, column 4.
147
148       tput cup
149            Send  the  terminfo string for cursor-movement, with no parameters
150            substituted.
151
152       tput longname
153            Print the long name from the terminfo database  for  the  type  of
154            terminal specified in the environmental variable TERM.
155
156            tput -S <<!
157            > clear
158            > cup 10 10
159            > bold
160            > !
161
162            This  example  shows  tput  processing several capabilities in one
163            invocation.  It clears the screen, moves the  cursor  to  position
164            10,  10 and turns on bold (extra bright) mode.  The list is termi‐
165            nated by an exclamation mark (!) on a line by itself.
166

FILES

168       /usr/share/terminfo
169              compiled terminal description database
170
171       /usr/share/tabset/*
172              tab settings for some terminals, in a format appropriate  to  be
173              output  to  the  terminal (escape sequences that set margins and
174              tabs); for more information, see the "Tabs  and  Initialization"
175              section of terminfo(5)
176

EXIT CODES

178       If the -S option is used, tput checks for errors from each line, and if
179       any errors are found, will set the exit code to 4 plus  the  number  of
180       lines  with  errors.   If  no errors are found, the exit code is 0.  No
181       indication of which line failed can be given so exit code 1 will  never
182       appear.   Exit codes 2, 3, and 4 retain their usual interpretation.  If
183       the -S option is not used, the exit code depends on the  type  of  cap‐
184       name:
185
186            boolean
187                   a value of 0 is set for TRUE and 1 for FALSE.
188
189            string a value of 0 is set if the capname is defined for this ter‐
190                   minal type (the value of capname is  returned  on  standard
191                   output);  a value of 1 is set if capname is not defined for
192                   this terminal type (nothing is written to standard output).
193
194            integer
195                   a value of 0 is always  set,  whether  or  not  capname  is
196                   defined for this terminal type.  To determine if capname is
197                   defined for this terminal type,  the  user  must  test  the
198                   value written to standard output.  A value of -1 means that
199                   capname is not defined for this terminal type.
200
201            other  reset or init may fail to find their respective files.   In
202                   that case, the exit code is set to 4 + errno.
203
204       Any other exit code indicates an error; see the DIAGNOSTICS section.
205

DIAGNOSTICS

207       tput  prints  the  following  error messages and sets the corresponding
208       exit codes.
209
210       exit code   error message
211       ─────────────────────────────────────────────────────────────────────
212       0           (capname is a numeric variable that is not specified  in
213                   the  terminfo(5)  database  for this terminal type, e.g.
214                   tput -T450 lines and tput -T2621 xmc)
215       1           no error message is printed, see the EXIT CODES section.
216       2           usage error
217       3           unknown terminal type or no terminfo database
218       4           unknown terminfo capability capname
219       >4          error occurred in -S
220       ─────────────────────────────────────────────────────────────────────
221

PORTABILITY

223       The longname and -S options, and  the  parameter-substitution  features
224       used in the cup example, are not supported in BSD curses or in AT&T/USL
225       curses before SVr4.
226
227       X/Open documents only the operands for clear, init and reset.  In  this
228       implementation,  clear is part of the capname support.  Other implemen‐
229       tations of tput on SVr4-based systems such as Solaris, IRIX64 and  HPUX
230       as well as others such as AIX and Tru64 provide support for capname op‐
231       erands.
232
233       A few platforms such as FreeBSD  and  NetBSD  recognize  termcap  names
234       rather  than  terminfo  capability  names in their respective tput com‐
235       mands.
236
237       Most implementations which provide support for capname operands use the
238       tparm  function  to  expand  parameters in it.  That function expects a
239       mixture of numeric and string parameters, requiring tput to know  which
240       type  to  use.   This implementation uses a table to determine that for
241       the standard capname operands, and an internal library function to ana‐
242       lyze  nonstandard  capname  operands.  Other implementations may simply
243       guess that an operand containing only digits is intended to be  a  num‐
244       ber.
245

SEE ALSO

247       clear(1), stty(1), tabs(1), terminfo(5), curs_termcap(3X).
248
249       This describes ncurses version 5.9 (patch 20130511).
250
251
252
253                                                                       tput(1)
Impressum