Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Add custom prompt_restore_preview
- X-seq: zsh-workers 53414
- From: Frank Dana <ferdnyc@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Add custom prompt_restore_preview
- Date: Wed, 26 Mar 2025 10:39:01 -0400
- Archived-at: <https://zsh.org/workers/53414>
- List-id: <zsh-workers.zsh.org>
Attached (again, sorry, GMail) is a patch to the prompt_restore_setup
"theme" file, which prevents it from being previewed with the default
prompt_preview_theme.
Because 'restore' is NOT a theme, per se, it can't really be usefully
previewed. And attempting to preview it either alone ('prompt -p
restore') or as part of the default preview listing that shows all but
the current theme ('prompt -p') can cause terminal badness that
interferes with the preview of the other themes.
This patch solves that by adding a custom preview function to the
"theme" file, which instead of previewing anything just prints this
message:
The prompt command 'restore' is not a theme and cannot be previewed.
...An alternative approach (possibly better, but also more involved)
to addressing this would be to modify promptinit so it just silently
excluded 'restore' (and possibly other non-theme "themes") from the
list of themes to preview.
This was way easier, though.
From 3e0201349a48174e09e69845cf23443846fb65c7 Mon Sep 17 00:00:00 2001
From: "FeRD (Frank Dana)" <ferdnyc@xxxxxxxxx>
Date: Mon, 24 Mar 2025 23:49:46 -0400
Subject: [PATCH] Add custom prompt_restore_preview
Because 'restore' isn't a prompt per se, and can't usefully be
previewed with 'prompt_preview_theme', add a custom preview
function that mentions this fact instead of displaying a preview.
Prevents 'prompt -p' or 'prompt -p restore' from messing up the
terminal output and (in the 'prompt -p' case) interfering with the
previews of other themes.
---
Functions/Prompts/prompt_restore_setup | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/Functions/Prompts/prompt_restore_setup b/Functions/Prompts/prompt_restore_setup
index b77dbe815..c1f9bfb7e 100644
--- a/Functions/Prompts/prompt_restore_setup
+++ b/Functions/Prompts/prompt_restore_setup
@@ -1,3 +1,11 @@
-# Damn that was easy
-zstyle -t :prompt-theme cleanup
-zstyle -t :prompt-theme restore
+prompt_restore_setup () {
+ # Damn that was easy
+ zstyle -t :prompt-theme cleanup
+ zstyle -t :prompt-theme restore
+}
+
+prompt_restore_preview () {
+ echo "The prompt command 'restore' is not a theme and cannot be previewed."
+}
+
+prompt_restore_setup "$@"
--
2.49.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author