Clear scrollback in Putty

When I’m running commands with a lot of output via an SSH shell (I use Putty) I like to have a long buffer and scroll back through the output. However, if I’ve already run a lot of other commands then it’s difficult to see when the output of the last command started. I found a useful printf sequence that can be used to clear the buffer in Putty (can’t remember where I found it I’m afraid…).

vi ~/bin/clearandrun

Enter the script below:

#!/bin/bash
clear && printf '\033[3J';
$*

Then chmod +x ~/bin/clearandrun and you can now precede any command with clearandrun to clear the screen and scrollback before running the command.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.