gclear(1) User commands gclear(1)

gclear - clear the terminal screen

gclear [-x] [-T terminal-type]

gclear -V

gclear clears your terminal's screen and its scrollback buffer, if any. gclear retrieves the terminal type from the environment variable TERM, then consults the terminfo terminal capability database entry for that type to determine how to perform these actions.

The capabilities to clear the screen and scrollback buffer are named “clear” and “E3”, respectively. The latter is a user-defined capability, applying an extension mechanism introduced in ncurses 5.0 (1999).

gclear recognizes the following options.

produces instructions suitable for the terminal type. Normally, this option is unnecessary, because the terminal type is inferred from the environment variable TERM. If this option is specified, gclear ignores the environment variables LINES and COLUMNS as well.
reports the version of ncurses associated with this program and exits with a successful status.
prevents gclear from attempting to clear the scrollback buffer.

Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor X/Open Curses Issue 7 documents gclear.

The latter documents tput, which could be used to replace this utility either via a shell script or by an alias (such as a symbolic link) to run gtput as gclear.

A clear command using the termcap database and library appeared in 2BSD (1979). Eighth Edition Unix (1985) later included it.

The commercial Unix arm of AT&T adapted a different BSD program (tset) to make a new command, tput, and replaced the clear program with a shell script that called “tput clear”.

/usr/bin/tput ${1:+-T$1} clear 2> /dev/null
exit

In 1989, when Keith Bostic revised the BSD tput command to make it similar to AT&T's tput, he added a clear shell script as well.

exec tput clear

The remainder of the script in each case is a copyright notice.

In 1995, ncurses's clear began by adapting BSD's original clear command to use terminfo. The E3 extension came later.

In June 1999, xterm provided an extension to the standard control sequence for clearing the screen. Rather than clearing just the visible part of the screen using

printf '\033[2J'
one could clear the scrollback buffer as well by using

printf '\033[3J'
instead. “XTerm Control Sequences” documents this feature as originating with xterm.

gtput(1), xterm(1), terminfo(5)

2024-03-16 ncurses 6.5