Is there a builtin command to clear shell while using shell in emacs?
If not, is there an elisp function to achieve the same?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Update February 2015
Just noticed that Emacs now (version 25+) has the command
comint-clear-buffer, bound toC-c M-oby default, that does what we need here, and probably is preferable to the answers I originally posted below.Options to consider:
C-lwill recenter the buffer. Pressing it repeatedly cycles the buffer, so that point appears at the top, middle, or bottom of the buffer. When it stops at the top, the buffer looks like it’s been cleared, although all the text is still there, out of view.C-x hmarks the whole buffer, after whichC-wkills it. This kills the last prompt as well, but after you enter the next command you get your prompt back.You can also use
erase-buffer, which isn’t bound to a key by default, but it’s easily done (you can also useM-x erase-buffer:That binds it to
C-c l; you can pick what you like.After you’ve been using emacs for a while, marking and killing regions becomes natural, so you might find the first option is enough. If not, the last option is closest to what you want.
EDIT: just found this on the emacs wiki, it’s better than my option 4: