How do I get the 'clear' command in Cygwin?

I installed Cygwin, choosing a fairly minimal set of packages.

In a terminal, I tried to do 'clear' to clear the terminal, but I get

bash: clear: command not found

How do I get this to work?


Solution 1:

Install the Cygwin package ncurses; it is in the Utils category.

Solution 2:

This should do:

alias clear='printf "\033c"'

Solution 3:

just use this shortcut: Alt+F8 and Ctrl-L to skip page

Solution 4:

Use cygcheck command to check what package it is in (adding .exe to your cmd string, in this example: clear.exe)

> cygcheck -p 'clear.exe'
Found 4 matches for clear.exe
ncurses-debuginfo-5.9-20150307-1 - ncurses-debuginfo: Debug info for ncurses (installed binaries and support files)
ncurses-debuginfo-5.9-20150404-1 - ncurses-debuginfo: Debug info for ncurses (installed binaries and support files)
ncurses-5.9-20150307-1 - ncurses: Terminal display utilities (installed binaries and support files)
ncurses-5.9-20150404-1 - ncurses: Terminal display utilities (installed binaries and support files)

and you know you have to install ncurses package using cygwin installer.

Solution 5:

It's nice to have the clear.exe program for bash script files, so:

Windows Cygwin detail for clear.exe program command.

  1. Download Cygwin setupx86.exe or whatever it's call at http://cygwin.com/

  2. Run it and download from internet. *If you have a proxy connection, you may need to use Internet Explorer settings or set up custom proxy.

  3. Choose all default settings, and finish the installation.

  4. Run the installer a second time and again download from internet, but this time you will go into Utils, when it comes to the tree of files to customize your installation.

  5. Expand Utils and get down to the ncurses" files. There, you will click on the skip item, to the left of the ncurses utils (there are a few).

  6. After changing from skip to whatever version of ncurses you want to install, continue the installation, and finish.

  7. Run the installer again and this time you will expand Lib aka libraries.

  8. Find the terminfo library installer, and again change skip to the newest version, then continue and complete the installation.

NOTE You might end up having to log out of Windows and log back in, or just reboot before the new programs take effect. This is due to the possibility of Cygwin background session.

NOTE You also must do the three separate installations.