Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I connect to my server via PuTTY, I can clear the visible screen with the clear command.

However, I can still scroll backwards in PuTTY's GUI to see the old stuff. I am aware of PuTTY's Clear Scrollback feature, but that requires mouse clicking.

I'd like to perform that exact same "Clear Scrollback" operation, but from the commandline.

Is it possible?

I read this site, which seems to indicate so.

However, my experiments have failed. For instance:

printf '\033[3J'

Does nothing, for me.

I may not be understanding the meaning of CSI 3 J in that second link, though...

share|improve this question
    
What version of PuTTY are you using? The page indicates the feature works in PuTTY 0.59 and above. I have PuTTY 0.60 and it works for me. Note it only clears the scrollback buffer, it doesn't clear the screen. (If I have a scroll bar I can actually scroll, then use this sequence, I notice the scroll bar become disabled because there's suddenly nothing available to scroll to. But the currently displayed screen remains in place.) –  Bavi_H Feb 22 '13 at 2:56
    
@Bavi_H: ah, thank you - I was not realizing that it won't affect the currently displayed text. I see it is working, too. The full solution I want is clear && printf '\033[3J'. If you make an answer, I'll accept it. –  jwd Feb 22 '13 at 3:10

1 Answer 1

up vote 11 down vote accepted

The CSI 3 J sequence to clear the scrollback buffer was added to PuTTY 0.59. (On the wish request page for this feature see the "fixed-in" line, or go to the PuTTY changes page and search for CSI 3 J.)

As jwd mentioned, you can enter printf '\033[3J' on a command line to send this sequence to the PuTTY. Be aware this only clears the scrollback buffer, it doesn't clear the screen. If you have a scroll bar you can actually scroll, then use this sequence, you'll see the scroll bar become disabled because there's suddenly nothing available to scroll to. But the currently displayed screen remains in place.

As jwd mentioned, you can clear both the screen and the scrollback buffer using clear && printf '\033[3J'

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.