diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -190,7 +190,7 @@ if (el != NULL) { if (hist) el_set(el, EL_HIST, history, hist); - el_set(el, EL_PROMPT, getprompt); + el_set(el, EL_PROMPT_ESC, getprompt, '\001'); el_set(el, EL_ADDFN, "sh-complete", "Filename completion", sh_complete); diff --git a/bin/sh/parser.c b/bin/sh/parser.c --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -2060,6 +2060,15 @@ if (*fmt == '\\') switch (*++fmt) { + /* + * ESC character. + */ + case 'e': + ps[i++] = '\001'; + ps[i++] = '\033'; + ps[i] = '\001'; + break; + /* * Hostname. * diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -32,7 +32,7 @@ .\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" $FreeBSD$ .\" -.Dd May 10, 2021 +.Dd December 14, 2022 .Dt SH 1 .Os .Sh NAME @@ -1428,6 +1428,8 @@ may include any of the following formatting sequences, which are replaced by the given information: .Bl -tag -width indent +.It Li \ee +An ASCII ESCAPE character (decimal 27, octal 033, hexadecimal 0x1b). .It Li \eH This system's fully-qualified hostname (FQDN). .It Li \eh