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 be ignored,and the operating system will not be
45              queried for the actual screen size.
46
47       capname
48              indicates the capability from the terminfo database.  When term‐
49              cap  support is compiled in, the termcap name for the capability
50              is also accepted.
51
52       parms  If the capability is a string that takes parameters,  the  argu‐
53              ments parms will be instantiated into the string.
54
55              Most  parameters  are numbers.  Only a few terminfo capabilities
56              require string parameters; tput uses a table to decide which  to
57              pass  as  strings.  Normally tput uses tparm (3X) to perform the
58              substitution.  If no parameters are given  for  the  capability,
59              tput writes the string without performing the substitution.
60
61       -S     allows  more  than  one  capability per invocation of tput.  The
62              capabilities must be passed to  tput  from  the  standard  input
63              instead  of  from the command line (see example).  Only one cap‐
64              name is allowed per line.  The -S option changes the meaning  of
65              the  0  and  1 boolean and string exit codes (see the EXIT CODES
66              section).
67
68              Again, tput uses a table and the presence of parameters  in  its
69              input  to decide whether to use tparm (3X), and how to interpret
70              the parameters.
71
72       -V     reports the version of ncurses which was used in  this  program,
73              and exits.
74
75       init   If  the terminfo database is present and an entry for the user's
76              terminal exists (see -Ttype, above), the following will occur:
77
78              (1)    if present, the terminal's initialization strings will be
79                     output as detailed in the terminfo(5) section on Tabs and
80                     Initialization,
81
82              (2)    any delays (e.g., newline) specified in the entry will be
83                     set in the tty driver,
84
85              (3)    tabs  expansion will be turned on or off according to the
86                     specification in the entry, and
87
88              (4)    if tabs are not  expanded,  standard  tabs  will  be  set
89                     (every 8 spaces).
90
91              If  an  entry does not contain the information needed for any of
92              the four  above  activities,  that  activity  will  silently  be
93              skipped.
94
95       reset  Instead  of  putting  out initialization strings, the terminal's
96              reset strings will be output if present (rs1, rs2, rs3, rf).  If
97              the  reset  strings  are not present, but initialization strings
98              are, the initialization  strings  will  be  output.   Otherwise,
99              reset acts identically to init.
100
101       longname
102              If  the terminfo database is present and an entry for the user's
103              terminal exists (see -Ttype above), then the long  name  of  the
104              terminal will be put out.  The long name is the last name in the
105              first line of the terminal's description in the  terminfo  data‐
106              base [see term(5)].
107
108       If  tput  is invoked by a link named reset, this has the same effect as
109       tput reset.  See tset for comparison, which has similar behavior.
110

EXAMPLES

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

FILES

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

EXIT CODES

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

DIAGNOSTICS

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

PORTABILITY

224       The  longname  and  -S options, and the parameter-substitution features
225       used in the cup example, are not supported in BSD curses or in AT&T/USL
226       curses before SVr4.
227
228       X/Open  documents only the operands for clear, init and reset.  In this
229       implementation, clear is part of the capname support.  Other  implemen‐
230       tations  of tput on SVr4-based systems such as Solaris, IRIX64 and HPUX
231       as well as others such as AIX and Tru64 provide support for capname op‐
232       erands.   A  few platforms such as FreeBSD and NetBSD recognize termcap
233       names rather than terminfo capability names in  their  respective  tput
234       commands.
235

SEE ALSO

237       clear(1), stty(1), tabs(1), terminfo(5).
238
239       This describes ncurses version 5.7 (patch 20100703).
240
241
242
243                                                                       tput(1)
Impressum