Is there a command to clear a Cygwin console?

4

3

Is there a command to clear all of the history in a Cygwin console window without losing the .bash_history?

erikvold

Posted 2011-03-11T20:26:40.307

Reputation: 3 077

This is a duplicate of this question, except that it isn't as well written. If you had written your question better, Erik Vold, without misnaming terminal output as "history" for starters, you wouldn't have had to explain what you were asking over and over in comments. This should be closed as a duplicate.

– JdeBP – 2011-03-11T22:13:15.950

@JdeBP did you try the solution mentioned there? it does not work.. – erikvold – 2011-03-11T22:28:46.177

3@JdeBP Cygwin != *nix console... So, no dupe IMHO... Please don't be too harsh, try to be constructive in your criticism... – BloodPhilia – 2011-03-11T22:31:24.940

Answers

8

Click Ctrl-L. It should clear everything without losing the .bash_history. `

paradd0x

Posted 2011-03-11T20:26:40.307

Reputation: 7 771

1If necessary, you could embed ^L in a script, or even change the Bash prompt to clear the screen after each command. – CarlF – 2011-03-11T21:54:30.497

1Doesn't this just move previous output off screen? – Juan Mendes – 2013-02-04T20:53:35.253

5

If you mean you want to clear the console window: install ncurses (in Utils) and then you can use:

clear

Reg Whitton

Posted 2011-03-11T20:26:40.307

Reputation: 51

1

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!

wreckseal

Posted 2011-03-11T20:26:40.307

Reputation: 11

1

I use Alt+F8 and the screen is like you have just open a fresh cygwin!

carlitos081

Posted 2011-03-11T20:26:40.307

Reputation: 11

0

There are two simple ways:

  1. Type the command clear
  2. Ctrl+L

zakariya

Posted 2011-03-11T20:26:40.307

Reputation: 9