0

I know that we can clear the entire buffer by using one of the following, as referenced here:

+ K

printf '\33c\e[3J'

However, is it possible to clear the entire buffer except the last n lines?

dillon
  • 721
  • 6
  • 16
  • Do not think it is possible in "right way" But you can detect window height/width and print spaces on all lines except last n lines. – Saboteur Oct 07 '21 at 23:31

1 Answers1

0

You can clear the text on the current screen (up to the cursor position) using a different parameter (documented in XTerm Control Sequences):

printf '\033[1J'

Unlike \033[3J, this is a standard sequence which you may find in ECMA-48. Apple provides no relevant documentation.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105