I am using emacs s 23.1.1.
I have started to really use in real-earnest the shell, in order to minimize the amounts of time I am out of emacs. However, the bind-keys are emacs based. Which is good, but has its' limitations. if I want to use CTRL-r in the shell-context (loop backward over commands input), and not in the emacs context, how do I do that?
Having a preceding bind-key is O.K. I.e. press bindy key ALT-CTRL-S, and then CTRL-r.
2 Answers
By default the binding to do this in Emacs' shell-mode is M-r which runs the command comint-history-isearch-backward-regexp
. This allows you to search backwards though your input history using a regular expression.
Personally I prefer the comint-previous-matching-input-from-input
command, which is by default bound to C-c M-r. I have it bound to the slightly more convenient M-p and it allows me to type the first few characters of the command I want, and to then use M-p to cycle through all previous inputs that begin with this prefix.
Consider using term-mode
rather than shell-mode
. In term-mode
you can switch between "character mode" (where commands like C-r
go directly to the terminal) and "line mode" (where commands are first interpreted by Emacs). C-c C-j
activates line mode and C-c C-k
character mode. Character mode gives C-r
the behavior you want while line mode makes the terminal act more like a normal Emacs buffer.
nil
inshell-mode-map
.term
oransi-term
.