]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/clear.1
ncurses 6.4 - patch 20231007
[ncurses.git] / man / clear.1
1 .\"***************************************************************************
2 .\" Copyright 2018-2022,2023 Thomas E. Dickey                                *
3 .\" Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
4 .\"                                                                          *
5 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
6 .\" copy of this software and associated documentation files (the            *
7 .\" "Software"), to deal in the Software without restriction, including      *
8 .\" without limitation the rights to use, copy, modify, merge, publish,      *
9 .\" distribute, distribute with modifications, sublicense, and/or sell       *
10 .\" copies of the Software, and to permit persons to whom the Software is    *
11 .\" furnished to do so, subject to the following conditions:                 *
12 .\"                                                                          *
13 .\" The above copyright notice and this permission notice shall be included  *
14 .\" in all copies or substantial portions of the Software.                   *
15 .\"                                                                          *
16 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23 .\"                                                                          *
24 .\" Except as contained in this notice, the name(s) of the above copyright   *
25 .\" holders shall not be used in advertising or otherwise to promote the     *
26 .\" sale, use or other dealings in this Software without prior written       *
27 .\" authorization.                                                           *
28 .\"***************************************************************************
29 .\"
30 .\" $Id: clear.1,v 1.41 2023/10/07 21:19:07 tom Exp $
31 .TH @CLEAR@ 1 2023-10-07 "ncurses 6.4" "User commands"
32 .ie \n(.g \{\
33 .ds `` \(lq
34 .ds '' \(rq
35 .ds '  \(aq
36 .\}
37 .el \{\
38 .ie t .ds `` ``
39 .el   .ds `` ""
40 .ie t .ds '' ''
41 .el   .ds '' ""
42 .ie t .ds '  \(aq
43 .el   .ds '  '
44 .\}
45 .
46 .de bP
47 .ie n  .IP \(bu 4
48 .el    .IP \(bu 2
49 ..
50 .
51 .ds n 5
52 .SH NAME
53 \fB\%@CLEAR@\fP \-
54 clear the terminal screen
55 .SH SYNOPSIS
56 .B @CLEAR@
57 .RB [ \-x ]
58 .RB [ \-T\ \c
59 .IR type ]
60 .PP
61 .B "@CLEAR@ \-V"
62 .SH DESCRIPTION
63 \fB\%@CLEAR@\fP clears your terminal's screen and its scrollback buffer,
64 if any.
65 \fB\%@CLEAR@\fP retrieves the terminal type from the environment
66 variable \fBTERM\fP,
67 then consults the \fIterminfo\fP terminal capability database entry for
68 that type to determine how to perform these actions.
69 .PP
70 The capabilities to clear the screen and scrollback buffer are named
71 \*(``clear\*('' and \*(``E3\*('', respectively.
72 The latter is a \fIuser-defined capability\fP,
73 applying an extension mechanism introduced in \fIncurses\fP 5.0 (1999).
74 .SH OPTIONS
75 \fB\%@CLEAR@\fP recognizes the following options.
76 .TP 9 \" "-T type" + 2n
77 .B \-T \fItype\fP
78 produces instructions suitable for the terminal \fItype\fP.
79 Normally,
80 this option is unnecessary,
81 because the terminal type is inferred from the environment variable
82 \fBTERM\fP.
83 If this option is specified,
84 \fB\%@CLEAR@\fP ignores the environment variables \fBLINES\fP and
85 \fB\%COLUMNS\fP as well.
86 .TP
87 .B \-V
88 reports the version of \fIncurses\fP associated with this program and
89 exits with a successful status.
90 .TP
91 .B \-x
92 prevents \fB\%@CLEAR@\fP from attempting to clear the scrollback buffer.
93 .SH HISTORY
94 A \fBclear\fP command using the \fItermcap\fP database and library
95 appeared in 2BSD (1979).
96 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
97 Eighth Edition Unix (1985) later included it.
98 .PP
99 The commercial Unix arm of AT&T adapted a different BSD program
100 (\fBtset\fP) to make a new command,
101 \fBtput\fP,
102 and replaced the \fBclear\fP program with a shell script that called
103 \*(``\fBtput clear\fP\*(''.
104 .PP
105 .RS 4
106 .EX
107 /usr/bin/tput ${1:+\-T$1} clear 2> /dev/null
108 exit
109 .EE
110 .RE
111 .PP
112 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
113 to make it similar to AT&T's \fBtput\fP,
114 he added a \fBclear\fP shell script as well.
115 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/\
116 .\"   tput/clear.sh
117 .PP
118 .RS 4
119 .EX
120 exec tput clear
121 .EE
122 .RE
123 .PP
124 The remainder of the script in each case is a copyright notice.
125 .PP
126 In 1995,
127 \fIncurses\fP's \fBclear\fP began by adapting BSD's original \fBclear\fP
128 command to use \fIterminfo\fP.
129 The \fBE3\fP extension came later.
130 .bP
131 In June 1999, \fIxterm\fP provided an extension to the standard control
132 sequence for clearing the screen.
133 Rather than clearing just the visible part of the screen using
134 .RS 8
135 .PP
136 .EX
137 printf \*'\e033[2J\*'
138 .EE
139 .RE
140 .IP
141 one could clear the scrollback buffer using
142 .RS 8
143 .PP
144 .EX
145 printf \*'\e033[\fB3\fPJ\*'
146 .EE
147 .RE
148 .IP
149 instead.
150 \*(``XTerm Control Sequences\fP\*('' documents this feature as
151 originating with \fIxterm\fP.
152 .bP
153 A few other terminal emulators adopted it,
154 such as PuTTY in 2006.
155 .bP
156 In April 2011, a Red Hat developer submitted a patch to the Linux
157 kernel, modifying its console driver to do the same thing.
158 Documentation of this change,
159 appearing in Linux 3.0,
160 did not mention \fIxterm\fP,
161 although that program was cited in the Red Hat bug report (#683733)
162 motivating the feature.
163 .bP
164 Subsequently,
165 more terminal developers adopted the feature.
166 The next relevant step was to change the \fIncurses\fP \fBclear\fP
167 program in 2013 to incorporate this extension.
168 .bP
169 In 2013,
170 the \fBE3\fP capability was not exercised by
171 \*(``\fB\%@TPUT@ clear\fP\*(''.
172 That oversight was addressed in 2016 by reorganizing \fB\%@TPUT@\fP to
173 share its logic with \fB\%@CLEAR@\fP and \fB\%@TSET@\fP.
174 .SH PORTABILITY
175 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
176 (POSIX.1-2008) nor X/Open Curses Issue 7 documents \fB\%@TSET@\fP or
177 \fB\%@RESET@\fP.
178 .PP
179 The latter documents \fBtput\fP,
180 which could be used to replace this utility either via a shell script or
181 by an alias
182 (such as a symbolic link)
183 to run \fB\%@TPUT@\fP as \fB\%@CLEAR@\fP.
184 .SH SEE ALSO
185 \fB\%@TPUT@\fP(1),
186 \fB\%xterm\fP(1),
187 \fB\%terminfo\fP(\*n)