Clear console buffer in ConEmu with Cygwin

4

I've recently switched from using iterm in OSX to using Cygwin in ConEmu on Windows. One thing I'm really missing is the ability to completely clear the terminal buffer at any time using Alt+k. I've managed to get Alt+k to clear the buffer using a GuiMacro in ConEmu to run the command cmd /c cls using this approach:

ConEmu: Keyboard shortcut to run "cls[ENTER]"

The problem is that because it's a command, it doesn't work when I've just kicked off a process. The same limitation applies to Ctrl+l, which clears the current window but leaves the scrollback buffer in tact. What I'm really after is a way to completely clear the scrollback buffer at any time using a keyboard shortcut. Any ideas?

I'd also be interested to a lesser degree in doing the same thing in bash on linux (as I run it in a VM) and in the regular Windows cmd.exe.

Update: This seems to be possible when using the terminal in my IDE (Intellij), on all platforms. Unfortunately other limitations of running the terminal inside my IDE mean this isn't the solution I'm looking for.

Conan

Posted 2015-04-06T17:46:20.027

Reputation: 151

Why are you trying to run "cmd" from cygwin?? Ctrl+L clears cygwin screen. At that does not relate to ConEmu at all. – Maximus – 2015-04-06T18:12:49.420

I've had to use cmd to be able to clear the scrollback buffer, I haven't found another way of doing this in Cygwin alone. Or in bash in Ubuntu either, for that matter. – Conan – 2015-04-06T18:19:50.850

Answers

2

This clears scrollback buffer in cygwin bash

clear

or

echo -e '\0033\0143'

Maximus

Posted 2015-04-06T17:46:20.027

Reputation: 19 395

OK great, echo -e '\0033\0143' clears the buffer in the same way as cmd /c cls, but is better as I don't need to shell out to cmd. I still can't use it whilst another command is running, however - do you know of a way to make that possible? – Conan – 2015-04-06T22:30:38.940

You must not do that. When another command is running, any significant modification of buffer may damage program output, or even lead to its crush. – Maximus – 2015-04-07T06:50:19.530

2But I've never had a problem with exactly that behaviour in iTerm, where it is standard. I'd like to replicate that useful behaviour on other platforms. – Conan – 2015-04-07T07:21:18.357

1Update: Not sure if this changed recently, but clear does not work (any more?). The echo sequence still does clear the scrollback buffer though. I'm almost sure clear worked until recently, until I installed the latest conEmu update. – Mörre – 2015-09-11T14:27:39.940

Working as expected. – Maximus – 2015-09-11T15:18:36.377

1

The developer has addressed this: https://conemu.github.io/en/ClearScreen.html

Scott Coldwell

Posted 2015-04-06T17:46:20.027

Reputation: 111