Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restoring content from a cleared terminal on Mac OS

Tags:

terminal

macos

After clearing a Mac terminal (via Command K, or the "Clear All" command under the edit menu), is there a way to easily restore the previously cleared text?

Periodically, when I run a long process on a Mac Terminal (such as a suite of unit tests) I prefer to clear the terminal. I do this so when I'm scrolling up to look over the results of the process, I can focus ONLY on the results of that process and not other commands I've recently run. (Such as, say, a different suite of tests)

But, sometimes I do eventually want to go back and look over the previous suit of tests.

Is there a way to restore previous terminal text?

like image 903
Raemon Avatar asked Oct 16 '15 20:10

Raemon


1 Answers

The terminal is not going to help with restoring the text. It is gone.

If you anticipate wanting to review the text, you could (in a more or less transparent manner—not interfering with your work) run your session in script. That records everything sent to the terminal (including escape sequences for vi).

If your use of the terminal is largely just cat'ing files or watching logs, then the resulting typescript file is usable with less -R. It does not work well with cursor-movement, but for those, I use slowcat or similar filters to slowly cat a file, etc. For best results, the terminal emulator interprets escape sequences reliably.

like image 131
Thomas Dickey Avatar answered Oct 25 '22 08:10

Thomas Dickey