]> ncurses.scripts.mit.edu Git - ncurses.git/blob - man/clear.1
ncurses 6.4 - patch 20231217
[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.46 2023/12/16 20:32:22 tom Exp $
31 .TH @CLEAR@ 1 2023-12-16 "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 \fI\%ncurses\fP 5.0
73 (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 \fITERM\fP.
83 If this option is specified,
84 \fB\%@CLEAR@\fP ignores the environment variables \fILINES\fP and
85 \fI\%COLUMNS\fP as well.
86 .TP
87 .B \-V
88 reports the version of \fI\%ncurses\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 PORTABILITY
94 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
95 (POSIX.1-2008) nor X/Open Curses Issue 7 documents \fB\%@CLEAR@\fP.
96 .PP
97 The latter documents \fBtput\fP,
98 which could be used to replace this utility either via a shell script or
99 by an alias
100 (such as a symbolic link)
101 to run \fB\%@TPUT@\fP as \fB\%@CLEAR@\fP.
102 .SH HISTORY
103 A \fBclear\fP command using the \fItermcap\fP database and library
104 appeared in 2BSD (1979).
105 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
106 Eighth Edition Unix (1985) later included it.
107 .PP
108 The commercial Unix arm of AT&T adapted a different BSD program
109 (\fBtset\fP) to make a new command,
110 \fBtput\fP,
111 and replaced the \fBclear\fP program with a shell script that called
112 \*(``\fBtput clear\fP\*(''.
113 .PP
114 .RS 4
115 .EX
116 /usr/bin/tput ${1:+\-T$1} clear 2> /dev/null
117 exit
118 .EE
119 .RE
120 .PP
121 In 1989, when Keith Bostic revised the BSD \fBtput\fP command
122 to make it similar to AT&T's \fBtput\fP,
123 he added a \fBclear\fP shell script as well.
124 .\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=Net2/usr/src/usr.bin/\
125 .\"   tput/clear.sh
126 .PP
127 .RS 4
128 .EX
129 exec tput clear
130 .EE
131 .RE
132 .PP
133 The remainder of the script in each case is a copyright notice.
134 .PP
135 In 1995,
136 \fI\%ncurses\fP's \fBclear\fP began by adapting BSD's original
137 \fBclear\fP command to use \fIterminfo\fP.
138 The \fBE3\fP extension came later.
139 .bP
140 In June 1999, \fIxterm\fP provided an extension to the standard control
141 sequence for clearing the screen.
142 Rather than clearing just the visible part of the screen using
143 .RS 8
144 .PP
145 .EX
146 printf \*'\e033[2J\*'
147 .EE
148 .RE
149 .IP
150 one could clear the scrollback buffer as well by using
151 .RS 8
152 .PP
153 .EX
154 printf \*'\e033[\fB3\fPJ\*'
155 .EE
156 .RE
157 .IP
158 instead.
159 \*(``XTerm Control Sequences\fP\*('' documents this feature as
160 originating with \fIxterm\fP.
161 .bP
162 A few other terminal emulators adopted it,
163 such as PuTTY in 2006.
164 .bP
165 In April 2011, a Red Hat developer submitted a patch to the Linux
166 kernel, modifying its console driver to do the same thing.
167 Documentation of this change,
168 appearing in Linux 3.0,
169 did not mention \fIxterm\fP,
170 although that program was cited in the Red Hat bug report (#683733)
171 motivating the feature.
172 .bP
173 Subsequently,
174 more terminal developers adopted the feature.
175 The next relevant step was to change the \fI\%ncurses\fP \fBclear\fP
176 program in 2013 to incorporate this extension.
177 .bP
178 In 2013,
179 the \fBE3\fP capability was not exercised by
180 \*(``\fB\%@TPUT@ clear\fP\*(''.
181 That oversight was addressed in 2016 by reorganizing \fB\%@TPUT@\fP to
182 share its logic with \fB\%@CLEAR@\fP and \fB\%@TSET@\fP.
183 .SH SEE ALSO
184 \fB\%@TPUT@\fP(1),
185 \fB\%xterm\fP(1),
186 \fB\%terminfo\fP(5)