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.

2
  • Why are you trying to run "cmd" from cygwin?? Ctrl+L clears cygwin screen. At that does not relate to ConEmu at all.
    – Maximus
    Apr 6, 2015 at 18:12
  • 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
    Apr 6, 2015 at 18:19

3 Answers 3

2

This clears scrollback buffer in cygwin bash

clear

or

echo -e '\0033\0143'
5
  • 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
    Apr 6, 2015 at 22:30
  • 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
    Apr 7, 2015 at 6:50
  • 2
    But 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
    Apr 7, 2015 at 7:21
  • 1
    Update: 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
    Sep 11, 2015 at 14:27
  • Working as expected.
    – Maximus
    Sep 11, 2015 at 15:18
0

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

0
  • Go to

    Settings -> Keys & Macro

  • Select Macros in dropdown menu

  • Choose an empty Macro

  • Set key to Ctrl+L

  • Set GUI Macro to

    print("echo -e \"\\0033\\0143\"\n")
    
  • Save settings

1
  • 1
    This doesn't address the problem as it only works when the prompt is available, not when a foreground application is running. iterm2 on OSX is able to clear the entire buffer, and handles the situations described by the dev linked in Scott Coldwell's answer. This behaviour is what I'm after. The use case for this is a long-running application which is printing logs to the console; I want to test the application, but want to clear the logs before performing some action, so I know all the logs relate only to that action. Also I've already linked this solution in the question.
    – Conan
    Jun 18, 2020 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .