I run lots of test in shell-mode because I love being able to search through the history. However, some of these tests print lots of info to stdout and will cause my memory usage to go through the roof after a long period of time. I have to manually delete the history to keep the memory in check. Is there a way to tell shell-mode to discard old messages after so many lines?

1 Answer 1


Yes, if you want to make shell buffers limited in length, add the function comint-truncate-buffer to comint-output-filter-functions. You should be able to add this to your .emacs:

(add-hook 'comint-output-filter-functions #'comint-truncate-buffer)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.