]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/clear.1
ncurses 6.4 - patch 20231202
[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.45 2023/12/02 20:49:04 tom Exp $
31 .TH @CLEAR@ 1 2023-12-02 "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 .SH NAME
52 \fB\%@CLEAR@\fP \-
53 clear the terminal screen
54 .SH SYNOPSIS
55 .B @CLEAR@
56 .RB [ \-x ]
57 .RB [ \-T\ \c
58 .IR terminal-type ]
59 .PP
60 .B "@CLEAR@ \-V"
61 .SH DESCRIPTION
62 \fB\%@CLEAR@\fP clears your terminal's screen and its scrollback buffer,
63 if any.
64 \fB\%@CLEAR@\fP retrieves the terminal type from the environment
65 variable \fITERM\fP,
66 then consults the \fIterminfo\fP terminal capability database entry for
67 that type to determine how to perform these actions.
68 .PP
69 The capabilities to clear the screen and scrollback buffer are named
70 \*(``clear\*('' and \*(``E3\*('', respectively.
71 The latter is a \fIuser-defined capability\fP,
72 applying an extension mechanism introduced in \fIncurses\fP 5.0 (1999).
73 .SH OPTIONS
74 \fB\%@CLEAR@\fP recognizes the following options.
75 .TP 9 \" "-T type" + 2n
76 .B \-T \fItype\fP
77 produces instructions suitable for the terminal \fItype\fP.
78 Normally,
79 this option is unnecessary,
80 because the terminal type is inferred from the environment variable
81 \fITERM\fP.
82 If this option is specified,
83 \fB\%@CLEAR@\fP ignores the environment variables \fILINES\fP and
84 \fI\%COLUMNS\fP as well.
85 .TP
86 .B \-V
87 reports the version of \fIncurses\fP associated with this program and
88 exits with a successful status.
89 .TP
90 .B \-x
91 prevents \fB\%@CLEAR@\fP from attempting to clear the scrollback buffer.
92 .SH PORTABILITY
93 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
94 (POSIX.1-2008) nor X/Open Curses Issue 7 documents \fB\%@CLEAR@\fP.
95 .PP
96 The latter documents \fBtput\fP,
97 which could be used to replace this utility either via a shell script or
98 by an alias
99 (such as a symbolic link)
100 to run \fB\%@TPUT@\fP as \fB\%@CLEAR@\fP.
101 .SH HISTORY
102 A \fBclear\fP command using the \fItermcap\fP database and library
103 appeared in 2BSD (1979).
104 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
105 Eighth Edition Unix (1985) later included it.
106 .PP
107 The commercial Unix arm of AT&T adapted a different BSD program
108 (\fBtset\fP) to make a new command,
109 \fBtput\fP,
110 and replaced the \fBclear\fP program with a shell script that called
111 \*(``\fBtput clear\fP\*(''.
112 .PP
113 .RS 4
114 .EX
115 /usr/bin/tput ${1:+\-T$1} clear 2> /dev/null
116 exit
117 .EE
118 .RE
119 .PP
120 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
121 to make it similar to AT&T's \fBtput\fP,
122 he added a \fBclear\fP shell script as well.
123 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/\
124 .\"   tput/clear.sh
125 .PP
126 .RS 4
127 .EX
128 exec tput clear
129 .EE
130 .RE
131 .PP
132 The remainder of the script in each case is a copyright notice.
133 .PP
134 In 1995,
135 \fIncurses\fP's \fBclear\fP began by adapting BSD's original \fBclear\fP
136 command to use \fIterminfo\fP.
137 The \fBE3\fP extension came later.
138 .bP
139 In June 1999, \fIxterm\fP provided an extension to the standard control
140 sequence for clearing the screen.
141 Rather than clearing just the visible part of the screen using
142 .RS 8
143 .PP
144 .EX
145 printf \*'\e033[2J\*'
146 .EE
147 .RE
148 .IP
149 one could clear the scrollback buffer as well by using
150 .RS 8
151 .PP
152 .EX
153 printf \*'\e033[\fB3\fPJ\*'
154 .EE
155 .RE
156 .IP
157 instead.
158 \*(``XTerm Control Sequences\fP\*('' documents this feature as
159 originating with \fIxterm\fP.
160 .bP
161 A few other terminal emulators adopted it,
162 such as PuTTY in 2006.
163 .bP
164 In April 2011, a Red Hat developer submitted a patch to the Linux
165 kernel, modifying its console driver to do the same thing.
166 Documentation of this change,
167 appearing in Linux 3.0,
168 did not mention \fIxterm\fP,
169 although that program was cited in the Red Hat bug report (#683733)
170 motivating the feature.
171 .bP
172 Subsequently,
173 more terminal developers adopted the feature.
174 The next relevant step was to change the \fIncurses\fP \fBclear\fP
175 program in 2013 to incorporate this extension.
176 .bP
177 In 2013,
178 the \fBE3\fP capability was not exercised by
179 \*(``\fB\%@TPUT@ clear\fP\*(''.
180 That oversight was addressed in 2016 by reorganizing \fB\%@TPUT@\fP to
181 share its logic with \fB\%@CLEAR@\fP and \fB\%@TSET@\fP.
182 .SH SEE ALSO
183 \fB\%@TPUT@\fP(1),
184 \fB\%xterm\fP(1),
185 \fB\%terminfo\fP(5)