From 2f2bbc485f2263ab8eb9d272a22d32c06f9e94e9 Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Tue, 30 Mar 2021 11:37:29 +0200 Subject: [PATCH] sh: improve emacs mode In emacs mode, force ^R to backware search the history This behaviour is the default in emacs mode for most of the other shells Note: Note that this can still be overridden via $EDITRC, ~/.editrc or a bind command after set -o emacs. Approved by: jilles Reviewed by: jilles, arichardson, pstef Differential Revision: https://reviews.freebsd.org/D29494 (cherry picked from commit 660045fb5360d328da199ae78c89d5cc15b6d1ca) --- bin/sh/histedit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index a46fe946df18..81967a8a503d 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -139,8 +139,10 @@ bad: if (el) { if (Vflag) el_set(el, EL_EDITOR, "vi"); - else if (Eflag) + else if (Eflag) { el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_BIND, "^R", "em-inc-search-prev", NULL); + } el_set(el, EL_BIND, "^I", "sh-complete", NULL); el_source(el, NULL); }