blob: a1034db7cb1a98ce34fc8a13063fc1e81d4b3e2a [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301.\"***************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002.\" Copyright 2018-2023,2024 Thomas E. Dickey *
3.\" Copyright 1998-2016,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304.\" *
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.\"
micky3879b9f5e72025-07-08 18:04:53 -040030.\" $Id: clear.1,v 1.48 2024/03/16 15:35:01 tom Exp $
31.TH @CLEAR@ 1 2024-03-16 "ncurses @NCURSES_MAJOR@.@NCURSES_MINOR@" "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.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053051.SH NAME
micky3879b9f5e72025-07-08 18:04:53 -040052\fB\%@CLEAR@\fP \-
53clear the terminal screen
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053054.SH SYNOPSIS
micky3879b9f5e72025-07-08 18:04:53 -040055.B @CLEAR@
56.RB [ \-x ]
57.RB [ \-T\ \c
58.IR terminal-type ]
59.PP
60.B "@CLEAR@ \-V"
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053061.SH DESCRIPTION
micky3879b9f5e72025-07-08 18:04:53 -040062\fB\%@CLEAR@\fP clears your terminal's screen and its scrollback buffer,
63if any.
64\fB\%@CLEAR@\fP retrieves the terminal type from the environment
65variable \fITERM\fP,
66then consults the \fIterminfo\fP terminal capability database entry for
67that type to determine how to perform these actions.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053068.PP
micky3879b9f5e72025-07-08 18:04:53 -040069The capabilities to clear the screen and scrollback buffer are named
70\*(``clear\*('' and \*(``E3\*('', respectively.
71The latter is a \fIuser-defined capability\fP,
72applying 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
78produces instructions suitable for the terminal \fItype\fP.
79Normally,
80this option is unnecessary,
81because the terminal type is inferred from the environment variable
82\fITERM\fP.
83If 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
88reports the version of \fI\%ncurses\fP associated with this program and
89exits with a successful status.
90.TP
91.B \-x
92prevents \fB\%@CLEAR@\fP from attempting to clear the scrollback buffer.
93.SH PORTABILITY
94Neither 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
97The latter documents \fBtput\fP,
98which could be used to replace this utility either via a shell script or
99by an alias
100(such as a symbolic link)
101to run \fB\%@TPUT@\fP as \fB\%@CLEAR@\fP.
102.SH HISTORY
103A \fBclear\fP command using the \fItermcap\fP database and library
104appeared in 2BSD (1979).
105.\" https://minnie.tuhs.org/cgi-bin/utree.pl?file=2BSD/src/clear.c
106Eighth Edition Unix (1985) later included it.
107.PP
108The commercial Unix arm of AT&T adapted a different BSD program
109(\fBtset\fP) to make a new command,
110\fBtput\fP,
111and 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
117exit
118.EE
119.RE
120.PP
121In 1989, when Keith Bostic revised the BSD \fBtput\fP command
122to make it similar to AT&T's \fBtput\fP,
123he 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
129exec tput clear
130.EE
131.RE
132.PP
133The remainder of the script in each case is a copyright notice.
134.PP
135In 1995,
136\fI\%ncurses\fP's \fBclear\fP began by adapting BSD's original
137\fBclear\fP command to use \fIterminfo\fP.
138The \fBE3\fP extension came later.
139.bP
140In June 1999, \fIxterm\fP provided an extension to the standard control
141sequence for clearing the screen.
142Rather than clearing just the visible part of the screen using
143.RS 8
144.PP
145.EX
146printf \*'\e033[2J\*'
147.EE
148.RE
149.IP
150one could clear the scrollback buffer as well by using
151.RS 8
152.PP
153.EX
154printf \*'\e033[\fB3\fPJ\*'
155.EE
156.RE
157.IP
158instead.
159\*(``XTerm Control Sequences\fP\*('' documents this feature as
160originating with \fIxterm\fP.
161.bP
162A few other terminal emulators adopted it,
163such as PuTTY in 2006.
164.bP
165In April 2011, a Red Hat developer submitted a patch to the Linux
166kernel, modifying its console driver to do the same thing.
167Documentation of this change,
168appearing in Linux 3.0,
169did not mention \fIxterm\fP,
170although that program was cited in the Red Hat bug report (#683733)
171motivating the feature.
172.bP
173Subsequently,
174more terminal developers adopted the feature.
175The next relevant step was to change the \fI\%ncurses\fP \fBclear\fP
176program in 2013 to incorporate this extension.
177.bP
178In 2013,
179the \fBE3\fP capability was not exercised by
180\*(``\fB\%@TPUT@ clear\fP\*(''.
181That oversight was addressed in 2016 by reorganizing \fB\%@TPUT@\fP to
182share its logic with \fB\%@CLEAR@\fP and \fB\%@TSET@\fP.
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530183.SH SEE ALSO
micky3879b9f5e72025-07-08 18:04:53 -0400184\fB\%@TPUT@\fP(1),
185\fB\%xterm\fP(1),
186\fB\%terminfo\fP(5)