In bash, I can clear the screen with the clear command and I can clear the whole "buffer" with the reset command.

I'm looking to accomplish the reset in Emacs *shell* terminal. Is there a command / keyboard binding for this?


Answering my own question. Found the answer on this site:

(defun clear-shell ()
  (let ((old-max comint-buffer-maximum-size))
    (setq comint-buffer-maximum-size 0)
    (setq comint-buffer-maximum-size old-max))) 

Then I also added a key-binding:

(global-set-key "\C-f" 'clear-shell)
  • I bind C-x h to 'mark-whole-buffer (which works in any mode/buffer) then just use C-w to kill the region. The above global-set-key will rebind C-f in all modes, not just your shell, which will hide the default C-f forward-char binding. – djb Oct 6 '17 at 20:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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