Changing tabs in Terminal is very slow with lots of output

terminal

I frequently have Terminal open with several tabs. I have noticed that sometimes switching to a new tab takes several minutes, during which Terminal appears to hang with a busy cursor.

I suspect that cause is running programs in that tab with very verbose debug output, that is producing extremely long lines. I know that sometimes there are single lines with megabytes of text in them, and it's possible that the lines have tens or hundreds of megabytes.

One solution to the problem is to run those commands as command_with_long_output | cut -c 1-1000, but I have a tendency to forget to do that, especially if I'm switching from running a test data set (where the lines are maybe a few kilobytes) to running the full data set.

I'm hoping for a setting of "Only keep 1M of data" or "Only keep first 20k characters per line", but I don't see anything like that.

Best Answer

Go to Terminal / Preferences / Profiles / Window / Scrollback / Limit the number of rows to:

enter image description here