1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
4 ****************************************************************************
5 * Copyright (c) 1998-2002,2003 Free Software Foundation, Inc. *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
30 ****************************************************************************
31 * @Id: tput.1,v 1.20 2003/05/11 00:32:53 tom Exp @
36 <link rev=made href="mailto:bug-ncurses@gnu.org">
37 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
43 <!-- Manpage converted by man2html 3.0.1 -->
44 <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG> <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
51 <STRONG>tput</STRONG>, <STRONG>reset</STRONG> - initialize a terminal or query terminfo
56 <H2>SYNOPSIS</H2><PRE>
57 <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <EM>capname</EM> [<EM>parms</EM> ... ]
58 <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>init</STRONG>
59 <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>reset</STRONG>
60 <STRONG>tput</STRONG> [<STRONG>-T</STRONG><EM>type</EM>] <STRONG>longname</STRONG>
61 <STRONG>tput</STRONG> <STRONG>-S</STRONG> <STRONG><<</STRONG>
62 <STRONG>tput</STRONG> <STRONG>-V</STRONG>
66 <H2>DESCRIPTION</H2><PRE>
67 The <STRONG>tput</STRONG> utility uses the <STRONG>terminfo</STRONG> database to make the
68 values of terminal-dependent capabilities and information
69 available to the shell (see <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>), to initialize or reset
70 the terminal, or return the long name of the requested
71 terminal type. <STRONG>tput</STRONG> outputs a string if the attribute
72 (<EM>cap</EM>ability <EM>name</EM>) is of type string, or an integer if the
73 attribute is of type integer. If the attribute is of type
74 boolean, <STRONG>tput</STRONG> simply sets the exit code (<STRONG>0</STRONG> for TRUE if the
75 terminal has the capability, <STRONG>1</STRONG> for FALSE if it does not),
76 and produces no output. Before using a value returned on
77 standard output, the user should test the exit code [<STRONG>$?</STRONG>,
78 see <STRONG><A HREF="sh.1.html">sh(1)</A></STRONG>] to be sure it is <STRONG>0</STRONG>. (See the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> and
79 <STRONG>DIAGNOSTICS</STRONG> sections.) For a complete list of capabili-
80 ties and the <EM>capname</EM> associated with each, see <STRONG>ter-</STRONG>
81 <STRONG><A HREF="terminfo.1.html">minfo(1)</A></STRONG>.
83 <STRONG>-T</STRONG><EM>type</EM> indicates the <EM>type</EM> of terminal. Normally this
84 option is unnecessary, because the default is taken
85 from the environment variable <STRONG>TERM</STRONG>. If <STRONG>-T</STRONG> is spec-
86 ified, then the shell variables <STRONG>LINES</STRONG> and <STRONG>COLUMNS</STRONG>
87 will be ignored,and the operating system will not
88 be queried for the actual screen size.
91 indicates the attribute from the <STRONG>terminfo</STRONG> database.
92 When <STRONG>termcap</STRONG> support is compiled in, the <STRONG>termcap</STRONG>
93 name for the attribute is also accepted.
95 <EM>parms</EM> If the attribute is a string that takes parameters,
96 the arguments <EM>parms</EM> will be instantiated into the
97 string. An all-numeric argument will be passed to
98 the attribute as a number.
100 Only a few terminfo capabilities require string
101 parameters; <STRONG>tput</STRONG> uses a table to decide which to
102 pass as strings. Normally <STRONG>tput</STRONG> uses <STRONG>tparm</STRONG> (3x) to
103 perform the substitution. If no parameters are
104 given for the attribute, <STRONG>tput</STRONG> writes the string
105 without performing the substitution.
107 <STRONG>-S</STRONG> allows more than one capability per invocation of
108 <STRONG>tput</STRONG>. The capabilities must be passed to <STRONG>tput</STRONG> from
109 the standard input instead of from the command line
110 (see example). Only one <EM>capname</EM> is allowed per
111 line. The <STRONG>-S</STRONG> option changes the meaning of the <STRONG>0</STRONG>
112 and <STRONG>1</STRONG> boolean and string exit codes (see the EXIT
115 Again, <STRONG>tput</STRONG> uses a table and the presence of
116 parameters in its input to decide whether to use
117 <STRONG>tparm</STRONG> (3x), and how to interpret the parameters.
119 <STRONG>-V</STRONG> reports the version of ncurses which was used in
120 this program, and exits.
122 <STRONG>init</STRONG> If the <STRONG>terminfo</STRONG> database is present and an entry
123 for the user's terminal exists (see <STRONG>-T</STRONG><EM>type</EM>, above),
124 the following will occur: (1) if present, the ter-
125 minal's initialization strings will be output (<STRONG>is1</STRONG>,
126 <STRONG>is2</STRONG>, <STRONG>is3</STRONG>, <STRONG>if</STRONG>, <STRONG>iprog</STRONG>), (2) any delays (e.g., new-
127 line) specified in the entry will be set in the tty
128 driver, (3) tabs expansion will be turned on or off
129 according to the specification in the entry, and
130 (4) if tabs are not expanded, standard tabs will be
131 set (every 8 spaces). If an entry does not contain
132 the information needed for any of the four above
133 activities, that activity will silently be skipped.
135 <STRONG>reset</STRONG> Instead of putting out initialization strings, the
136 terminal's reset strings will be output if present
137 (<STRONG>rs1</STRONG>, <STRONG>rs2</STRONG>, <STRONG>rs3</STRONG>, <STRONG>rf</STRONG>). If the reset strings are not
138 present, but initialization strings are, the ini-
139 tialization strings will be output. Otherwise,
140 <STRONG>reset</STRONG> acts identically to <STRONG>init</STRONG>.
142 <STRONG>longname</STRONG>
143 If the <STRONG>terminfo</STRONG> database is present and an entry
144 for the user's terminal exists (see <STRONG>-T</STRONG><EM>type</EM> above),
145 then the long name of the terminal will be put out.
146 The long name is the last name in the first line of
147 the terminal's description in the <STRONG>terminfo</STRONG> database
148 [see <STRONG><A HREF="term.5.html">term(5)</A></STRONG>].
150 If <STRONG>tput</STRONG> is invoked by a link named <STRONG>reset</STRONG>, this has the
151 same effect as <STRONG>tput</STRONG> <STRONG>reset</STRONG>. See <STRONG>tset</STRONG> for comparison, which
152 has similar behavior.
156 <H2>EXAMPLES</H2><PRE>
157 <STRONG>tput</STRONG> <STRONG>init</STRONG>
158 Initialize the terminal according to the type of ter-
159 minal in the environmental variable <STRONG>TERM</STRONG>. This com-
160 mand should be included in everyone's .profile after
161 the environmental variable <STRONG>TERM</STRONG> has been exported, as
162 illustrated on the <STRONG><A HREF="profile.5.html">profile(5)</A></STRONG> manual page.
164 <STRONG>tput</STRONG> <STRONG>-T5620</STRONG> <STRONG>reset</STRONG>
165 Reset an AT&T 5620 terminal, overriding the type of
166 terminal in the environmental variable <STRONG>TERM</STRONG>.
168 <STRONG>tput</STRONG> <STRONG>cup</STRONG> <STRONG>0</STRONG> <STRONG>0</STRONG>
169 Send the sequence to move the cursor to row <STRONG>0</STRONG>, column
170 <STRONG>0</STRONG> (the upper left corner of the screen, usually known
171 as the "home" cursor position).
173 <STRONG>tput</STRONG> <STRONG>clear</STRONG>
174 Echo the clear-screen sequence for the current termi-
177 <STRONG>tput</STRONG> <STRONG>cols</STRONG>
178 Print the number of columns for the current terminal.
180 <STRONG>tput</STRONG> <STRONG>-T450</STRONG> <STRONG>cols</STRONG>
181 Print the number of columns for the 450 terminal.
183 <STRONG>bold=`tput</STRONG> <STRONG>smso`</STRONG> <STRONG>offbold=`tput</STRONG> <STRONG>rmso`</STRONG>
184 Set the shell variables <STRONG>bold</STRONG>, to begin stand-out mode
185 sequence, and <STRONG>offbold</STRONG>, to end standout mode sequence,
186 for the current terminal. This might be followed by
187 a prompt: <STRONG>echo</STRONG> <STRONG>"${bold}Please</STRONG> <STRONG>type</STRONG> <STRONG>in</STRONG> <STRONG>your</STRONG> <STRONG>name:</STRONG>
188 <STRONG>${offbold}\c"</STRONG>
190 <STRONG>tput</STRONG> <STRONG>hc</STRONG>
191 Set exit code to indicate if the current terminal is
192 a hard copy terminal.
194 <STRONG>tput</STRONG> <STRONG>cup</STRONG> <STRONG>23</STRONG> <STRONG>4</STRONG>
195 Send the sequence to move the cursor to row 23, col-
198 <STRONG>tput</STRONG> <STRONG>cup</STRONG>
199 Send the terminfo string for cursor-movement, with no
200 parameters substituted.
202 <STRONG>tput</STRONG> <STRONG>longname</STRONG>
203 Print the long name from the <STRONG>terminfo</STRONG> database for
204 the type of terminal specified in the environmental
205 variable <STRONG>TERM</STRONG>.
207 <STRONG>tput</STRONG> <STRONG>-S</STRONG> <STRONG><<!</STRONG>
208 <STRONG>></STRONG> <STRONG>clear</STRONG>
209 <STRONG>></STRONG> <STRONG>cup</STRONG> <STRONG>10</STRONG> <STRONG>10</STRONG>
210 <STRONG>></STRONG> <STRONG>bold</STRONG>
211 <STRONG>></STRONG> <STRONG>!</STRONG>
213 This example shows <STRONG>tput</STRONG> processing several capabili-
214 ties in one invocation. It clears the screen, moves
215 the cursor to position 10, 10 and turns on bold
216 (extra bright) mode. The list is terminated by an
217 exclamation mark (<STRONG>!</STRONG>) on a line by itself.
222 <STRONG>/usr/share/terminfo</STRONG>
223 compiled terminal description database
225 <STRONG>/usr/include/curses.h</STRONG>
226 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG> header file
228 <STRONG>/usr/include/term.h</STRONG>
229 <STRONG>terminfo</STRONG> header file
231 <STRONG>/usr/share/tabset/*</STRONG>
232 tab settings for some terminals, in a format appro-
233 priate to be output to the terminal (escape
234 sequences that set margins and tabs); for more
235 information, see the "Tabs and Initialization" sec-
236 tion of <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
240 <H2>EXIT CODES</H2><PRE>
241 If the <STRONG>-S</STRONG> option is used, <STRONG>tput</STRONG> checks for errors from each
242 line, and if any errors are found, will set the exit code
243 to 4 plus the number of lines with errors. If no errors
244 are found, the exit code is <STRONG>0</STRONG>. No indication of which
245 line failed can be given so exit code <STRONG>1</STRONG> will never appear.
246 Exit codes <STRONG>2</STRONG>, <STRONG>3</STRONG>, and <STRONG>4</STRONG> retain their usual interpretation.
247 If the <STRONG>-S</STRONG> option is not used, the exit code depends on the
248 type of <EM>capname</EM>:
251 a value of <STRONG>0</STRONG> is set for TRUE and <STRONG>1</STRONG> for FALSE.
253 <EM>string</EM> a value of <STRONG>0</STRONG> is set if the <EM>capname</EM> is defined
254 for this terminal <EM>type</EM> (the value of <EM>capname</EM>
255 is returned on standard output); a value of <STRONG>1</STRONG>
256 is set if <EM>capname</EM> is not defined for this ter-
257 minal <EM>type</EM> (nothing is written to standard
261 a value of <STRONG>0</STRONG> is always set, whether or not
262 <EM>capname</EM> is defined for this terminal <EM>type</EM>. To
263 determine if <EM>capname</EM> is defined for this ter-
264 minal <EM>type</EM>, the user must test the value writ-
265 ten to standard output. A value of <STRONG>-1</STRONG> means
266 that <EM>capname</EM> is not defined for this terminal
269 <EM>other</EM> <STRONG>reset</STRONG> or <STRONG>init</STRONG> may fail to find their respec-
270 tive files. In that case, the exit code is
271 set to 4 + <STRONG>errno</STRONG>.
273 Any other exit code indicates an error; see the DIAGNOS-
278 <H2>DIAGNOSTICS</H2><PRE>
279 <STRONG>tput</STRONG> prints the following error messages and sets the cor-
280 responding exit codes.
282 exit code error message
283 ---------------------------------------------------------------------
284 <STRONG>0</STRONG> (<EM>capname</EM> is a numeric variable that is not specified in
285 the <STRONG><A HREF="terminfo.1.html">terminfo(1)</A></STRONG> database for this terminal type, e.g.
286 <STRONG>tput</STRONG> <STRONG>-T450</STRONG> <STRONG>lines</STRONG> and <STRONG>tput</STRONG> <STRONG>-T2621</STRONG> <STRONG>xmc</STRONG>)
287 <STRONG>1</STRONG> no error message is printed, see the <STRONG>EXIT</STRONG> <STRONG>CODES</STRONG> section.
288 <STRONG>2</STRONG> usage error
289 <STRONG>3</STRONG> unknown terminal <EM>type</EM> or no <STRONG>terminfo</STRONG> database
290 <STRONG>4</STRONG> unknown <STRONG>terminfo</STRONG> capability <EM>capname</EM>
291 <STRONG>>4</STRONG> error occurred in -S
292 ---------------------------------------------------------------------
296 <H2>PORTABILITY</H2><PRE>
297 The <STRONG>longname</STRONG> and <STRONG>-S</STRONG> options, and the parameter-substitu-
298 tion features used in the <STRONG>cup</STRONG> example, are not supported
299 in BSD curses or in AT&T/USL curses before SVr4.
303 <H2>SEE ALSO</H2><PRE>
304 <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>, <STRONG><A HREF="stty.1.html">stty(1)</A></STRONG>, <STRONG><A HREF="tabs.1.html">tabs(1)</A></STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>.
308 <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>
312 Man(1) output converted with
313 <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>