From 0f1c35e4c05e021198d75d94ad2dc6b987cc72a2 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 17 May 2023 09:59:48 -0400 Subject: [PATCH] Support color in shell-prompt-pattern shell-prompt-pattern works well, but it doesn't support escape characters coming after the prompt like tramp-shell-prompt-pattern. This change adds matching for escape characters, and also switches it to be defined with rx for clarity. As a side-effect, this fixes Bug#63539 * lisp/shell.el (shell-prompt-pattern): Switch to rx and allow color codes after the prompt. --- lisp/shell.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index 5cf108bfa3b..16cd5d42998 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -122,9 +122,12 @@ shell-dumb-shell-regexp :type 'regexp :group 'shell) -(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" +(defcustom shell-prompt-pattern (rx (* (not (any "#$%>\n"))) + (any "#$%>") + (* blank) + ;; Escape characters. + (* "[" (* (any ";" digit)) alpha (* blank))) "Regexp to match prompts in the inferior shell. -Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. This variable is used to initialize `comint-prompt-regexp' in the shell buffer. -- 2.30.2