Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: reset after highlighting groups in prompts
- X-seq: zsh-workers 54075
- From: Oliver Kiddle <opk@xxxxxxx>
- To: Zsh workers <zsh-workers@xxxxxxx>
- Subject: PATCH: reset after highlighting groups in prompts
- Date: Thu, 13 Nov 2025 03:38:49 +0100
- Archived-at: <https://zsh.org/workers/54075>
- List-id: <zsh-workers.zsh.org>
When %H was added for using highlight groups in prompts, I mentioned
that a way to to a reset was needed but was unsure on the best choice of
letter given the limited available choices. This uses %H without
following braces as suggested by Mikael at the time.
Oliver
diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo
index 9b713ce4a..d68f00826 100644
--- a/Doc/Zsh/prompt.yo
+++ b/Doc/Zsh/prompt.yo
@@ -256,6 +256,7 @@ braces so, for example tt(%H{error}) will use the highlighting specification
for the `error' group. If the key is not found in the associative array then
it has no effect. Highlighting specifications are in the same format as for
the tt(zle_highlight) parameter.
+If the following braces are absent, attributes are reset to the defaults.
)
item(tt(%{)...tt(%}))(
Include a string as a literal escape sequence.
diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index 0d86142c1..bb27ab9db 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -378,7 +378,8 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
fmt = parsehighlight(fmt + 1, '}', &atr, NULL);
if (atr && atr != TXT_ERROR)
treplaceattrs(atr);
- }
+ } else
+ treplaceattrs(0);
break;
case 'K':
if (*fmt == '{') {
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 4c87c15d7..9c26b6f99 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1186,7 +1186,9 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
p = parsehighlight(p + 1, '}', &atr, NULL);
if (atr != TXT_ERROR && dopr)
treplaceattrs(atr);
- }
+ } else
+ treplaceattrs(0);
+
break;
case ZWC('{'):
if (arg)
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index f399ebd00..8f32c68e3 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -2507,7 +2507,8 @@ printfmt(char *fmt, int n, int dopr, int doesc)
--p;
if (atr != TXT_ERROR)
treplaceattrs(atr);
- }
+ } else
+ treplaceattrs(0);
break;
case '{':
if (arg)
diff --git a/Src/prompt.c b/Src/prompt.c
index 161f49971..b1bb87e40 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -646,10 +646,12 @@ putpromptchar(int doprint, int endchar)
if (bv->fm[1] == '{') {
bv->fm = parsehighlight(bv->fm + 2, '}', &atr, NULL);
--bv->fm;
- if (atr != TXT_ERROR) {
- treplaceattrs(atr);
- applytextattributes(TSC_PROMPT);
- }
+ } else {
+ atr = 0;
+ }
+ if (atr != TXT_ERROR) {
+ treplaceattrs(atr);
+ applytextattributes(TSC_PROMPT);
}
break;
case '[':
Messages sorted by:
Reverse Date,
Date,
Thread,
Author