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