2 ****************************************************************************
3 * Copyright 2018-2023,2024 Thomas E. Dickey *
4 * Copyright 1998-2016,2017 Free Software Foundation, Inc. *
6 * Permission is hereby granted, free of charge, to any person obtaining a *
7 * copy of this software and associated documentation files (the *
8 * "Software"), to deal in the Software without restriction, including *
9 * without limitation the rights to use, copy, modify, merge, publish, *
10 * distribute, distribute with modifications, sublicense, and/or sell *
11 * copies of the Software, and to permit persons to whom the Software is *
12 * furnished to do so, subject to the following conditions: *
14 * The above copyright notice and this permission notice shall be included *
15 * in all copies or substantial portions of the Software. *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * Except as contained in this notice, the name(s) of the above copyright *
26 * holders shall not be used in advertising or otherwise to promote the *
27 * sale, use or other dealings in this Software without prior written *
29 ****************************************************************************
30 * @Id: clear.1,v 1.48 2024/03/16 15:35:01 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>clear 1 2024-03-16 ncurses 6.5 User commands</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">clear 1 2024-03-16 ncurses 6.5 User commands</H1>
44 <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG> User commands <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>clear</STRONG> - clear the terminal screen
53 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
54 <STRONG>clear</STRONG> [<STRONG>-x</STRONG>] [<STRONG>-T</STRONG> <EM>terminal-type</EM>]
56 <STRONG>clear</STRONG> <STRONG>-V</STRONG>
59 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
60 <STRONG>clear</STRONG> clears your terminal's screen and its scrollback buffer, if any.
61 <STRONG>clear</STRONG> retrieves the terminal type from the environment variable <EM>TERM</EM>,
62 then consults the <EM>terminfo</EM> terminal capability database entry for that
63 type to determine how to perform these actions.
65 The capabilities to clear the screen and scrollback buffer are named
66 "clear" and "E3", respectively. The latter is a <EM>user-defined</EM>
67 <EM>capability</EM>, applying an extension mechanism introduced in <EM>ncurses</EM> 5.0
71 </PRE><H2><a name="h2-OPTIONS">OPTIONS</a></H2><PRE>
72 <STRONG>clear</STRONG> recognizes the following options.
74 <STRONG>-T</STRONG> <EM>type</EM> produces instructions suitable for the terminal <EM>type</EM>.
75 Normally, this option is unnecessary, because the terminal
76 type is inferred from the environment variable <EM>TERM</EM>. If this
77 option is specified, <STRONG>clear</STRONG> ignores the environment variables
78 <EM>LINES</EM> and <EM>COLUMNS</EM> as well.
80 <STRONG>-V</STRONG> reports the version of <EM>ncurses</EM> associated with this program
81 and exits with a successful status.
83 <STRONG>-x</STRONG> prevents <STRONG>clear</STRONG> from attempting to clear the scrollback buffer.
86 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
87 Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7
88 (POSIX.1-2008) nor X/Open Curses Issue 7 documents <STRONG>clear</STRONG>.
90 The latter documents <STRONG>tput</STRONG>, which could be used to replace this utility
91 either via a shell script or by an alias (such as a symbolic link) to
92 run <STRONG>tput</STRONG> as <STRONG>clear</STRONG>.
95 </PRE><H2><a name="h2-HISTORY">HISTORY</a></H2><PRE>
96 A <STRONG>clear</STRONG> command using the <EM>termcap</EM> database and library appeared in 2BSD
97 (1979). Eighth Edition Unix (1985) later included it.
99 The commercial Unix arm of AT&T adapted a different BSD program (<STRONG>tset</STRONG>)
100 to make a new command, <STRONG>tput</STRONG>, and replaced the <STRONG>clear</STRONG> program with a
101 shell script that called "<STRONG>tput</STRONG> <STRONG>clear</STRONG>".
103 /usr/bin/tput ${1:+-T$1} clear 2> /dev/null
106 In 1989, when Keith Bostic revised the BSD <STRONG>tput</STRONG> command to make it
107 similar to AT&T's <STRONG>tput</STRONG>, he added a <STRONG>clear</STRONG> shell script as well.
111 The remainder of the script in each case is a copyright notice.
113 In 1995, <EM>ncurses</EM>'s <STRONG>clear</STRONG> began by adapting BSD's original <STRONG>clear</STRONG> command
114 to use <EM>terminfo</EM>. The <STRONG>E3</STRONG> extension came later.
116 <STRONG>o</STRONG> In June 1999, <EM>xterm</EM> provided an extension to the standard control
117 sequence for clearing the screen. Rather than clearing just the
118 visible part of the screen using
122 one could clear the scrollback buffer as well by using
124 printf '\033[<STRONG>3</STRONG>J'
126 instead. "XTerm Control Sequences" documents this feature as
127 originating with <EM>xterm</EM>.
129 <STRONG>o</STRONG> A few other terminal emulators adopted it, such as PuTTY in 2006.
131 <STRONG>o</STRONG> In April 2011, a Red Hat developer submitted a patch to the Linux
132 kernel, modifying its console driver to do the same thing.
133 Documentation of this change, appearing in Linux 3.0, did not
134 mention <EM>xterm</EM>, although that program was cited in the Red Hat bug
135 report (#683733) motivating the feature.
137 <STRONG>o</STRONG> Subsequently, more terminal developers adopted the feature. The
138 next relevant step was to change the <EM>ncurses</EM> <STRONG>clear</STRONG> program in 2013
139 to incorporate this extension.
141 <STRONG>o</STRONG> In 2013, the <STRONG>E3</STRONG> capability was not exercised by "<STRONG>tput</STRONG> <STRONG>clear</STRONG>". That
142 oversight was addressed in 2016 by reorganizing <STRONG>tput</STRONG> to share its
143 logic with <STRONG>clear</STRONG> and <STRONG>tset</STRONG>.
146 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
147 <STRONG><A HREF="tput.1.html">tput(1)</A></STRONG>, <STRONG>xterm(1)</STRONG>, <STRONG><A HREF="terminfo.5.html">terminfo(5)</A></STRONG>
151 ncurses 6.5 2024-03-16 <STRONG><A HREF="clear.1.html">clear(1)</A></STRONG>
155 <li><a href="#h2-NAME">NAME</a></li>
156 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
157 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
158 <li><a href="#h2-OPTIONS">OPTIONS</a></li>
159 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
160 <li><a href="#h2-HISTORY">HISTORY</a></li>
161 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>