www.delorie.com/gnu/docs/emacs/emacs_449.html   search  
 
Buy the book!


GNU Emacs Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

AC.15.4.3 Shell History References

Various shells including csh and bash support history references that begin with `!' and `^'. Shell mode recognizes these constructs, and can 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.

Shell mode can optionally expand history references in the buffer when you send them to the shell. To request this, set the variable comint-input-autoexpand to input. You can make SPC perform history expansion by binding SPC to the command comint-magic-space.

Shell mode recognizes history references when they follow a prompt. Normally, any text output by a program at the beginning of an input line is considered a prompt. However, if the variable comint-use-prompt-regexp-instead-of-fields is non-nil, then Comint mode uses a regular expression to recognize prompts. In general, the variable comint-prompt-regexp specifies the regular expression; Shell mode uses the variable shell-prompt-pattern to set up comint-prompt-regexp in the shell buffer.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003