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?
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?
Install the Cygwin package ncurses; it is in the Utils category.
This should do:
alias clear='printf "\033c"'
just use this shortcut: Alt+F8 and Ctrl-L to skip page
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.
It's nice to have the clear.exe program for bash script files, so:
Windows Cygwin detail for clear.exe program command.
Download Cygwin setupx86.exe or whatever it's call at http://cygwin.com/
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.
Choose all default settings, and finish the installation.
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.
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).
After changing from skip to whatever version of ncurses you want to install, continue the installation, and finish.
Run the installer again and this time you will expand Lib aka libraries.
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.
Right click > Reset... (Alt + F8) worked for me... (on Cygwin-x86-2.830)
Open Windows Explorer then navigate to:
[Cygwin Installation Directory]\home\[User]\
e.g.:  C:\cygwin\home\wreckseal
then open the file .bashrc with Notepad++.
Move your cursor at the end of the last line and hit Enter key, then add the text below.
alias cls='echo -e "\033c"'
or the text below:
alias cls='printf "\033c"'
Restart cygwin, type cls.  Done!
Note that there's no scrollbar after sending the cls command. I prefer the printf version than the echo version. Try it yourself!
TLDR: Package search uses regular expressions. So searching for regex "/clear.exe$" will give you the best match. This leads to the ncurses package.
General approach to such problems:
Search on the Cygwin-package search page with the full executable name.
Now the package search can be done in several ways:
Basic search by executable basename.
Package search for clear:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=clear
->  Found 600 matches for clear
Better matches by including the .exe suffix.
Package search for clear.exe:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=clear.exe
->  Found 14 matches for clear.exe
And even better matches by also including the / prefix.
Package search for /clear.exe:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=/clear.exe
->  Found 5 matches for /clear.exe
Best matches by also including the $ suffix.
(The $-sign means end-of-line in this regular expression.)
Package search for /clear.exe$:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=/clear.exe$
->  Found 3 matches for /clear.exe$
And all of these 3 matches are now from several versions of the ncurses package. So in order to get clear.exe you need to install ncurses.
(Pro tip: Right-click the search-field and create a customized search engine. I have set this to the shortcut cp for "cygwin package" in both Firefox and Chrome.)
I just came across this project and so far, I think it's awesome
https://github.com/transcode-open/apt-cyg
after installing it, you can run
apt-cyg install ncurses
I personally prefer installing libraries using this tool over the Cygwin tool b/c the Cygwin versions all have .exe appended to them, and can be cumbersome when copying and pasting Linux commands (off of SO, for instance).