Various shells including csh and bash support history references that begin with `!' and `^'. Shell mode can understand these constructs and perform the history substitution for you. If you insert a history reference and type TAB, this searches the input history for a matching command, performs substitution if necessary, and places the result in the buffer in place of the history reference. For example, you can fetch the most recent command beginning with `mv' with ! m v TAB. You can edit the command if you wish, and then resubmit the command to the shell by typing RET.
History references take effect only following a shell prompt. The
shell-prompt-pattern specifies how to recognize a shell
prompt. Comint modes in general use the variable
comint-prompt-regexp to specify how to find a prompt; Shell mode
shell-prompt-pattern to set up the local value of
Shell mode can optionally expand history references in the buffer when
you send them to the shell. To request this, set the variable
You can make SPC perform history expansion by binding SPC to
Go to the first, previous, next, last section, table of contents.