1tput(1)                          User Commands                         tput(1)
2
3
4

NAME

6       tput - initialize a terminal or query terminfo database
7

SYNOPSIS

9       tput [-T type] capname [parm]...
10
11
12       tput -S <<
13
14

DESCRIPTION

16       The  tput utility uses the terminfo database to make the values of ter‐
17       minal-dependent capabilities and information  available  to  the  shell
18       (see  sh(1));  to clear, initialize or reset the terminal; or to return
19       the long name of the requested terminal type. tput outputs a string  if
20       the  capability attribute (capname) is of type string, or an integer if
21       the attribute is of type integer. If the attribute is of type  boolean,
22       tput  simply  sets  the exit status (0 for TRUE if the terminal has the
23       capability, 1 for FALSE if it does not), and produces no output. Before
24       using  a  value  returned  on standard output, the user should test the
25       exit status ($?, see sh(1)) to be sure it is 0.  See  the  EXIT  STATUS
26       section.
27

OPTIONS

29       The following options are supported:
30
31       -Ttype     Indicates  the  type  of  terminal.  Normally this option is
32                  unnecessary, because the default is taken from the  environ‐
33                  ment variable TERM. If -T is specified, then the shell vari‐
34                  ables LINES and COLUMNS and the layer size will not be  ref‐
35                  erenced.
36
37
38       -S         Allows  more than one capability per invocation of tput. The
39                  capabilities must be passed to tput from the standard  input
40                  instead  of  from  the  command line (see the example in the
41                  EXAMPLES section). Only one capname is allowed per line. The
42                  -S  option  changes  the  meaning of the 0 and 1 boolean and
43                  string exit statuses (see the EXAMPLES section).
44
45

OPERANDS

47       The following operands are supported:
48
49       capname     Indicates the capability attribute from the terminfo  data‐
50                   base.  See  terminfo(4) for a complete list of capabilities
51                   and the capname associated with each.
52
53                   The following strings will be supported as operands by  the
54                   implementation in the "C" locale:
55
56                   clear        Display the clear-screen sequence.
57
58
59                   init         If  the  terminfo  database  is present and an
60                                entry for  the  user's  terminal  exists  (see
61                                -Ttype, above), the following will occur:
62
63                                    1.     if present, the terminal's initial‐
64                                           ization  strings  will  be   output
65                                           (is1, is2, is3, if, iprog),
66
67                                    2.     any  delays (for instance, newline)
68                                           specified in the entry will be  set
69                                           in the tty driver,
70
71                                    3.     tabs expansion will be turned on or
72                                           off according to the  specification
73                                           in the entry, and
74
75                                    4.     if  tabs are not expanded, standard
76                                           tabs will be set (every 8  spaces).
77                                           If  an  entry  does not contain the
78                                           information needed for any  of  the
79                                           four  above activities, that activ‐
80                                           ity will silently be skipped.
81
82
83                   reset        Instead of putting out initialization strings,
84                                the terminal's reset strings will be output if
85                                present (rs1, rs2,  rs3,  rf).  If  the  reset
86                                strings  are  not  present, but initialization
87                                strings are, the initialization  strings  will
88                                be  output.  Otherwise, reset acts identically
89                                to init.
90
91
92                   longname     If the terminfo database  is  present  and  an
93                                entry  for  the  user's  terminal  exists (see
94                                -Ttype above), then the long name of the  ter‐
95                                minal  will  be  put out. The long name is the
96                                last name in the first line of the  terminal's
97                                description  in  the  terminfo  database  (see
98                                term(5)).
99
100
101
102       parm        If the attribute is a string  that  takes  parameters,  the
103                   argument  parm will be instantiated into the string. An all
104                   numeric argument will be passed to the attribute as a  num‐
105                   ber.
106
107

EXAMPLES

109       Example 1 Initializing the terminal according to TERM
110
111
112       This example initializes the terminal according to the type of terminal
113       in the environment variable TERM. This command should  be  included  in
114       everyone's  .profile  after  the  environment  variable  TERM  has been
115       exported, as illustrated on the profile(4) manual page.
116
117
118         example% tput init
119
120
121
122       Example 2 Resetting a terminal
123
124
125       This example resets an AT&T 5620 terminal, overriding the type of  ter‐
126       minal in the environment variable TERM:
127
128
129         example% tput -T5620 reset
130
131
132
133       Example 3 Moving the cursor
134
135
136       The  following  example sends the sequence to move the cursor to row 0,
137       column 0 (the upper left corner of the screen,  usually  known  as  the
138       "home" cursor position).
139
140
141         example% tput cup 0 0
142
143
144
145
146       This next example sends the sequence to move the cursor to row 23, col‐
147       umn 4.
148
149
150         example% tput cup 23 4
151
152
153
154       Example 4 Echoing the clear-screen sequence
155
156
157       This example echos the clear-screen sequence for the current terminal.
158
159
160         example% tput clear
161
162
163
164       Example 5 Printing the number of columns
165
166
167       This command prints the number of columns for the current terminal.
168
169
170         example% tput cols
171
172
173
174
175       The following command prints the number of columns for the  450  termi‐
176       nal.
177
178
179         example% tput -T450 cols
180
181
182
183       Example 6 Setting shell variables
184
185
186       This  example  sets  the  shell variables bold, to begin stand-out mode
187       sequence, and offbold, to end standout mode sequence, for  the  current
188       terminal. This might be followed by a prompt:
189
190
191         echo "${bold}Please type in your name: ${offbold}\c"
192         example% bold='tput smso'
193         example% offbold='tput rmso'
194
195
196
197       Example 7 Setting the exit status
198
199
200       This  example  sets the exit status to indicate if the current terminal
201       is a hardcopy terminal.
202
203
204         example% tput hc
205
206
207
208       Example 8 Printing the long name from terminfo
209
210
211       This command prints the long name from the terminfo  database  for  the
212       type of terminal specified in the environment variable TERM.
213
214
215         example% tput longname
216
217
218
219       Example 9 Processing several capabilities with one invocation
220
221
222       This  example shows tput processing several capabilities in one invoca‐
223       tion. This example clears the screen, moves the cursor to position  10,
224       10  and turns on bold (extra bright) mode. The list is terminated by an
225       exclamation mark (!) on a line by itself.
226
227
228         example% tput -S <<!
229         > clear
230         > cup 10 10
231         > bold
232         > !
233
234
235

ENVIRONMENT VARIABLES

237       See environ(5) for descriptions of the following environment  variables
238       that affect the execution of tput: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
239       and NLSPATH.
240
241       TERM     Determine the terminal type. If  this  variable  is  unset  or
242                null,  and  if  the -T option is not specified, an unspecified
243                default terminal type will be used.
244
245

EXIT STATUS

247       The following exit values are returned:
248
249       0
250                     o      If capname is of type boolean and -S is not speci‐
251                            fied, indicates TRUE.
252
253                     o      If  capname is of type string and -S is not speci‐
254                            fied, indicates capname is defined for this termi‐
255                            nal type.
256
257                     o      If  capname is of type boolean or string and -S is
258                            specified, indicates that all lines were  success‐
259                            ful.
260
261                     o      capname is of type integer.
262
263                     o      The requested string was written successfully.
264
265
266       1
267                     o      If capname is of type boolean and -S is not speci‐
268                            fied, indicates FALSE.
269
270                     o      If capname is of type string and -S is not  speci‐
271                            fied,  indicates  that  capname is not defined for
272                            this terminal type.
273
274
275       2         Usage error.
276
277
278       3         No information is  available  about  the  specified  terminal
279                 type.
280
281
282       4         The specified operand is invalid.
283
284
285       >4        An error occurred.
286
287
288       −1        capname  is  a  numeric variable that is not specified in the
289                 terminfo database. For instance, tput -T450  lines  and  tput
290                 -T2621 xmc.
291
292

FILES

294       /usr/include/curses.h
295
296           curses(3CURSES) header
297
298
299       /usr/include/term.h
300
301           terminfo header
302
303
304       /usr/lib/tabset/*
305
306           Tab settings for some terminals, in a format appropriate to be out‐
307           put to the terminal (escape sequences that set margins  and  tabs).
308           For  more information, see the "Tabs and Initialization" section of
309           terminfo(4)
310
311
312       /usr/share/lib/terminfo/?/*
313
314           compiled terminal description database
315
316

ATTRIBUTES

318       See attributes(5) for descriptions of the following attributes:
319
320
321
322
323       ┌─────────────────────────────┬─────────────────────────────┐
324       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
325       ├─────────────────────────────┼─────────────────────────────┤
326       │Availability                 │SUNWcsu                      │
327       ├─────────────────────────────┼─────────────────────────────┤
328       │Interface Stability          │Standard                     │
329       └─────────────────────────────┴─────────────────────────────┘
330

SEE ALSO

332       clear(1), sh(1), stty(1), tabs(1),  curses(3CURSES),  profile(4),  ter‐
333       minfo(4), attributes(5), environ(5), standards(5), term(5)
334
335
336
337SunOS 5.11                        1 Feb 1995                           tput(1)
Impressum