2 .\"***************************************************************************
3 .\" Copyright 2018-2023,2024 Thomas E. Dickey *
4 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: tput.1,v 1.113 2024/04/20 19:58:50 tom Exp $
32 .TH @TPUT@ 1 2024-04-20 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "User commands"
51 initialize a terminal, exercise its capabilities, or query \fI\%term\%info\fP database
53 \fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP]
54 {\fIcap-code\fP [\fIparameter\fP .\|.\|.\&]} .\|.\|.
56 \fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] [\fB\-x\fP] \fBclear\fP
58 \fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fBinit\fP
60 \fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%reset\fP
62 \fB@TPUT@\fP [\fB\-T\fP \fIterminal-type\fP] \fB\%longname\fP
68 \fB\%@TPUT@\fP uses the
70 library and database to make terminal-specific capabilities and
71 information available to the shell,
72 to initialize or reset the terminal,
74 to report a description of the current
77 Terminal capabilities are accessed by
80 \fB\%terminfo\fP(5) discusses terminal capabilities at length
81 and presents a complete list of
84 When retrieving capability values,
85 the result depends upon the capability's type.
86 .TP 9 \" "Boolean" + 2n
88 \fB\%@TPUT@\fP sets its exit status to
90 if the terminal possesses
99 decimal value to the standard output stream if defined
102 followed by a newline.
105 \fB\%@TPUT@\fP writes
107 value to the standard output stream if defined,
108 without a trailing newline.
110 Before using a value returned on the standard output,
111 the application should test \fB\%@TPUT@\fP's exit status
113 see section \*(``EXIT STATUS\*('' below.
118 a capability code from the terminal database,
119 or a parameter thereto.
120 Three others are specially recognized by \fB\%@TPUT@\fP:
125 Although these resemble capability codes,
126 they in fact receive special handling;
127 we term them \*(``pseudo-capabilities\*(''.
128 .TP 11n \" "longname" + 2n + adjustment for PDF
130 indicates a capability from the terminal database.
134 is of string type and takes parameters,
135 \fB\%@TPUT@\fP interprets arguments following
138 up to the (fixed) quantity the capability requires.
140 Most parameters are numeric.
141 Only a few terminal capabilities require string parameters;
142 \fB\%@TPUT@\fP uses a table to decide which to pass as strings.
143 Normally \fB\%@TPUT@\fP uses \fB\%tparm\fP(3X) to perform the
145 If no parameters are given for the capability,
146 \fB\%@TPUT@\fP writes the string without performing the substitution.
149 initializes the terminal.
150 If the terminal database is present
151 and an entry for the user's terminal type exists,
156 \fB\%@TPUT@\fP retrieves the terminal's mode settings.
157 It successively tests the file descriptors corresponding to
160 the standard error stream,
162 the standard output stream,
164 the standard input stream,
170 to obtain terminal settings.
171 Having retrieved them,
172 \fB\%@TPUT@\fP remembers which descriptor to use for further updates.
175 If the terminal dimensions cannot be obtained from the operating system,
176 but the environment or terminal type database entry describes them,
177 \fB\%@TPUT@\fP updates the operating system's notion of them.
180 \fB\%@TPUT@\fP updates the terminal modes.
183 Any delays specified in the entry
185 when a newline is sent)
186 are set in the terminal driver.
188 Tab expansion is turned on or off per the specification in the entry,
191 if tabs are not expanded,
198 If initialization capabilities,
199 detailed in subsection \*(``Tabs and Initialization\*('' of
202 \fB\%@TPUT@\fP writes them to the standard output stream.
205 \fB\%@TPUT@\fP flushes the standard output stream.
208 If an entry lacks the information needed for an activity above,
209 that activity is silently skipped.
212 re-initializes the terminal.
213 A reset differs from initialization in two ways.
217 \fB\%@TPUT@\fP sets the the terminal modes to a \*(``sane\*('' state,
220 enabling cooked and echo modes,
222 disabling cbreak and raw modes,
224 enabling newline translation,
227 setting any unset special characters to their default values.
231 If any reset capabilities are defined for the terminal type,
232 \fB\%@TPUT@\fP writes them to the output stream.
234 \fB\%@TPUT@\fP uses any defined initialization capabilities.
235 Reset capabilities are detailed in subsection
236 \*(``Tabs and Initialization\*('' of \fB\%terminfo\fP(5).
242 entry begins with one or more names by which an application
243 can refer to the entry,
244 before the list of terminal capabilities.
245 The names are separated by \*(``|\*('' characters.
246 X/Open Curses terms the last name the \*(``long name\*('',
247 and indicates that it may include blanks.
249 \fB\%@TIC@\fP warns if the last name does not include blanks,
252 entries that treated the long name as an optional feature.
253 The long name is often referred to as the description field.
255 If the terminal database is present and an entry for the user's terminal
257 \fB\%@TPUT@\fP reports its description to the standard output stream,
258 without a trailing newline.
259 See \fB\%terminfo\fP(5).
262 Redirecting the output of
263 .RB \%\*(`` "@TPUT@ init" \*(''
265 .RB \%\*(`` "@TPUT@ reset" \*(''
266 to a file will capture only part of their actions.
267 Changes to the terminal modes are not affected by file descriptor
269 since the terminal modes are altered via \fB\%ioctl\fP(2).
271 If \fB\%@TPUT@\fP is invoked via link with any of the names
276 it operates as if run with the corresponding (pseudo-)capability
279 executing a link named
281 that points to \fB\%@TPUT@\fP has the same effect as
282 .RB \%\*(`` "@TPUT@ \%reset" \*(''.
284 This feature was introduced by
290 is a separate program,
291 which is both smaller and more frequently executed.
294 has the same name as another program in widespread use.
298 by the \fB\%@TSET@\fP(1) utility (also via a link named
301 Besides the pseudo-capabilities
304 \fB\%@TPUT@\fP treats the
310 it may call \fB\%setupterm\fP(3X) to obtain the terminal size.
313 \fB\%@TPUT@\fP attempts to obtain these capabilities from the terminal
315 This generally fails for terminal emulators,
316 which lack a fixed window size and thus omit the capabilities.
318 It then asks the operating system for the terminal's size,
319 which generally works,
320 unless the connection is via a serial line that
321 does not support \*(``NAWS\*('': negotiations about window size.
324 it inspects the environment variables
328 which may override the terminal size.
333 \fB\%@TPUT@\fP ignores the environment variables by calling
334 .BR \%use_tioctl(TRUE) ,
335 relying upon the operating system
338 the terminal database).
340 .TP 9n \" "-T type" + 2n
342 retrieves more than one capability per invocation of \fB\%@TPUT@\fP.
343 The capabilities must be passed to \fB\%@TPUT@\fP from the standard
344 input stream instead of from the command line
345 (see section \*(``EXAMPLES\*('' below).
351 option changes the meanings of the
356 (see section \*(``EXIT STATUS\*('' below).
358 Some capabilities use string parameters rather than numeric ones.
359 \fB\%@TPUT@\fP employs a built-in table and the presence of parameters
360 in its input to decide how to interpret them,
361 and whether to use \fB\%tparm\fP(3X).
364 indicates the terminal's
366 Normally this option is unnecessary,
367 because a default is taken from the
369 environment variable.
371 the environment variables
378 reports the version of
380 associated with \fB\%@TPUT@\fP,
381 and exits with a successful status.
385 .RB \%\*(`` "@TPUT@ clear" \*(''
386 from attempting to clear the scrollback buffer.
389 one should interpret \fB\%@TPUT@\fP's exit statuses as follows.
396 Status Meaning When \-S Not Specified
398 0 Boolean or string capability present
399 1 Boolean or numeric capability absent
400 2 usage error or no terminal type specified
401 3 unrecognized terminal type
402 4 unrecognized capability code
403 >4 system error (4 + \fBerrno\fP)
409 some statuses change meanings.
416 Status Meaning When \-S Specified
418 0 all operands interpreted
420 4 some operands not interpreted
423 \fB@TPUT@\fP reads one environment variable.
424 .TP 8n \" "TERM" + 2n + adjustment for PDF
426 denotes the terminal type.
427 Each terminal type is distinct,
428 though many are similar.
431 option overrides its value.
435 tab stop initialization database
438 compiled terminal description database
443 has differed from that of System\ V in two important respects,
444 one now mostly historical.
448 writes to the standard output,
449 which need not be a terminal device.
451 the operands that manipulate terminal modes might not use the standard
459 operands use logic from 4.1cBSD
461 manipulating terminal modes.
462 It checks the same file descriptors
465 for association with a terminal device as
469 finally assumes a 1200 baud terminal.
470 When updating terminal modes,
476 (see section \*(``HISTORY\*('' below),
477 \fB\%@TPUT@\fP did not modify terminal modes.
478 It now employs a scheme similar to System\ V,
479 using functions shared with \fB\%@TSET@\fP
480 (and ultimately based on 4.4BSD
482 If it is not able to open a terminal
484 when run by \fIcron\fP(1)),
485 \fB\%@TPUT@\fP exits with an error status.
489 assumes that the type of a
491 operand is numeric if all the characters of its value are decimal
496 as a string capability.
498 Most implementations that provide support for
500 operands use the \fB\%tparm\fP(3X) function to expand its parameters.
501 That function expects a mixture of numeric and string parameters,
502 requiring \fB\%@TPUT@\fP to know which type to use.
506 uses a table to determine the parameter types for
510 and an internal function to analyze nonstandard
514 While more reliable than System\ V's utility,
515 a portability problem is introduced by this analysis.
516 An OpenBSD developer adapted the internal library function from
523 and modified it to interpret multiple
527 Portable applications should not rely upon this feature;
529 offers it to support applications written specifically for OpenBSD.
540 support is compiled in.
562 .B \%parm_delete_line
569 .BR \%parm_delete_line .
580 .B \%exit_delete_mode
596 .BR \%exit_delete_mode .
603 and the parameter-substitution features used in the
606 were not supported in
611 4.3BSD-Reno (1990) added support for
613 .\" longname was added in October 1989.
615 NetBSD added support for the parameter-substitution features.
617 IEEE Std 1003.1/The Open Group Base Specifications Issue 7
625 A few observations of interest arise from that selection.
630 as it does any other standard
636 do not correspond to terminal capabilities.
640 on SVr4-based systems such as Solaris,
643 as well as others such as AIX and Tru64,
644 also support standard
648 A few platforms such as FreeBSD recognize
652 capability codes in their respective
679 Because (apparently) all
681 Unix systems support the full set of capability codes,
682 the reason for documenting only a few may not be apparent.
684 X/Open Curses Issue 7 documents
689 and the other features used in this implementation.
692 there are two standards for
694 POSIX (a subset) and X/Open Curses (the full implementation).
695 POSIX documents a subset to avoid the complication of including
696 X/Open Curses and the terminal capability database.
698 While it is certainly possible to write a
700 program without using
704 implementation provides a
706 utility that does not also support standard
709 X/Open Curses Issue 7 (2009) is the first version to document utilities.
710 However that part of X/Open Curses does not follow existing practice
716 It assigns exit status 4 to \*(``invalid operand\*('',
717 which may have the same meaning as \*(``unknown capability\*(''.
722 uses the term \*(``invalid\*('' in this case.
724 It assigns exit status 255 to a numeric variable that is not specified
728 That likely is a documentation error,
729 mistaking the \*(``\-1\*('' written to the standard output to indicate
730 an absent or cancelled numeric capability for an (unsigned) exit status.
732 The various System\ V implementations
736 use the same exit statuses as
741 documents exit statuses that correspond to neither
747 command during development of 4BSD in October 1980.
748 This initial version only cleared the screen,
749 and did not ship with official distributions.
750 .\" It also exited with backwards exit status (1 on success, 0 on
751 .\" failure), and was characterized by Bostic in 1988 as "pretty
753 .\" See Spinellis's "unix-history-repo" on GitHub.
755 System\ V developed a different
759 SVr2 (1984) provided a rudimentary
761 that checked the parameter against each
762 predefined capability and returned the corresponding value.
765 did not use \fB\%tparm\fP(3X) for parameterized capabilities.
767 SVr3 (1987) replaced that
768 .\" SVr3 released in 1987, not 1985.
769 .\" https://unix.org/what_is_unix/history_timeline.html
770 with a more extensive program
776 (more than half the program)
781 written by Eric Allman.
783 SVr4 (1989) added color initialization by using the
793 Keith Bostic refactored BSD
795 for shipment in 4.3BSD-Tahoe (1988),
796 then replaced it the next year with a new implementation based on
799 Bostic's version similarly accepted some parameters named for
801 (pseudo-)capabilities:
813 codes for other capabilities.
817 did not modify the terminal modes as the earlier BSD
822 Bostic added a shell script named \*(``clear\*('' that used
825 Both of these appeared in 4.4BSD,
826 becoming the \*(``modern\*('' BSD implementation of
831 \fB\%@TPUT@\fP lies outside both System\ V and BSD,
838 Ridge's program made more sophisticated use of the terminal capabilities
839 than the BSD program.
840 Eric Raymond used that
848 Incorporating the portions dealing with terminal capabilities
849 almost without change,
850 Raymond made improvements to the way command-line parameters
856 its \fB\%@TSET@\fP and \fB\%@TPUT@\fP utilities differed.
858 \fB\%@TSET@\fP was more effective,
859 resetting the terminal modes and special characters.
862 \fB\%@TSET@\fP's repertoire of terminal capabilities for resetting the
863 terminal was more limited;
864 it had only equivalents of
872 and not the tab stop and margin update features of \fB\%@TPUT@\fP.
876 program is traditionally an alias for \fB\%@TSET@\fP due to its ability
877 to reset terminal modes and special characters.
882 the \*(``reset\*('' features of the two programs are (mostly) the same.
883 Two minor differences remain.
885 The \fB\%@TSET@\fP program waits one second when resetting,
886 in case the terminal happens to be a hardware device.
888 The two programs write the terminal initialization strings
889 to different streams;
891 standard error for \fB\%@TSET@\fP and
892 standard output for \fB\%@TPUT@\fP.
896 Initialize the terminal according to the type of
899 environment variable.
900 If the system does not reliably initialize the terminal upon login,
901 this command can be included in
905 environment variable.
907 .B "@TPUT@ \-T5620 reset"
908 Reset an AT&T 5620 terminal,
909 overriding the terminal type in the
911 environment variable.
914 Set cursor to normal visibility.
917 Move the cursor to row 0,
919 the upper left corner of the screen,
920 usually known as the \*(``home\*('' cursor position.
926 capability's value to the standard output stream.
929 Report the number of columns used by the current terminal type.
931 .B "@TPUT@ \-Tadm3a cols"
932 Report the number of columns used by an ADM-3A terminal.
934 .B "strong=\(ga@TPUT@ smso\(ga normal=\(ga@TPUT@ rmso\(ga"
935 Set shell variables to capability values:
941 stand-out mode for the terminal.
942 One might use these to present a prompt.
946 printf "${strong}Username:${normal} "
951 Indicate via exit status whether the terminal is a hard copy device.
954 Move the cursor to row 23,
958 Report the value of the
962 (used for cursor movement),
963 with no parameters substituted.
968 database's description of the terminal type specified in the
970 environment variable.
973 Process multiple capabilities.
976 option can be profitably used with a shell \*(``here document\*(''.
979 .RB $\ "@TPUT@ \-S <<!"
988 moves the cursor to position
994 .B "@TPUT@ clear cup 10 10 bold"
995 Perform the same actions as the foregoing
996 .RB \%\*(`` "@TPUT@ \-S" \*(''
1003 \fB\%curs_termcap\fP(3X),