Interactive Shell Shell Shell History
Shell buffers use Shell mode, which defines several special keys attached to the C-c prefix. They are chosen to resemble the usual editing and job control characters present in shells that are not under Emacs, except that you must type C-c first. Here is a complete list of the special key bindings of Shell mode:
At end of buffer send line as input; otherwise, copy current line to end
of buffer and send it (
Complete the command name or file name before point in the shell buffer
Display temporarily a list of the possible completions of the file name
before point in the shell buffer
Either delete a character or send EOF
Move to the beginning of the line, but after the prompt if any
Accumulate multiple lines of input, then send them together. This
command inserts a newline before point, but does not send the preceding
text as input to the subshell---at least, not yet. Both lines, the one
before this newline and the one after, will be sent together (along with
the newline that separates them), when you type
Kill all text pending at end of buffer to be sent as input
Kill a word before point (
Interrupt the shell or its current subjob if any
Stop the shell or its current subjob if any (
Send quit signal to the shell or its current subjob if any
Kill the last batch of output from a shell command
Scroll to display the beginning of the last batch of output at the top
of the window; also move the cursor there (
Scroll to put the end of the buffer at the bottom of the window
Move forward across one shell command, but not beyond the current line
Move backward across one shell command, but not beyond the current line
Display the buffer's history of shell commands in another window
Ask the shell what its current directory is, so that Emacs can agree with the shell.
Send text as input to the shell, after reading it without echoing. This is useful when a shell command runs a program that asks for a password.
Alternatively, you can arrange for Emacs to notice password prompts and turn off echoing for them, as follows:
Continue the shell process. This is useful if you accidentally suspend the shell process.
Discard all control-M characters from the current group of shell output. The most convenient way to use this command is to make it run automatically when you get output from the subshell. To do that, evaluate this Lisp expression:
This command truncates the shell buffer to a certain maximum number of
lines, specified by the variable
Shell mode also customizes the paragraph commands so that only shell prompts start new paragraphs. Thus, a paragraph consists of an input command plus the output that follows it in the buffer.
Shell mode is a derivative of Comint mode, a general-purpose mode for communicating with interactive subprocesses. Most of the features of Shell mode actually come from Comint mode, as you can see from the command names listed above. The special features of Shell mode in particular include the choice of regular expression for detecting prompts, the directory tracking feature, and a few user commands.
Other Emacs features that use variants of Comint mode include GUD (see Debuggers) and M-x run-lisp (see External Lisp).
You can use M-x comint-run to execute any program of your choice in a subprocess using unmodified Comint mode---without the specializations of Shell mode.
 You should not suspend the shell process. Suspending a subjob of the shell is a completely different matter---that is normal practice, but you must use the shell to continue the subjob; this command won't do it.Interactive Shell Shell Shell History