Reputation: 411
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?
Upvotes: 15
Views: 14500
Reputation: 1581
When running the tests why not redirect the output to a file? This keeps your terminal clear and you can cat (or tail or more or less) that file to see only the results of that process. Another advantage is you can keep these log files around for future reference if needed.
Upvotes: 0
Reputation: 54475
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.
Upvotes: 3