From b69c7d07a1a26f498d211a0ad925749c9e13b307 Mon Sep 17 00:00:00 2001 From: mgpinf Date: Wed, 28 Aug 2024 23:50:08 +0530 Subject: [PATCH 1/3] option to configure PromptInputLine prompt - Introduces an option to set custom prompt text - If 'prompt' not passed in parameters, default value of "> " used --- config/src/keyassignment.rs | 7 +++++++ wezterm-gui/src/overlay/prompt.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs index ed284a5ec98..570cef942f3 100644 --- a/config/src/keyassignment.rs +++ b/config/src/keyassignment.rs @@ -460,6 +460,13 @@ pub struct PromptInputLine { /// Descriptive text to show ahead of prompt #[dynamic(default)] pub description: String, + /// Text to show for prompt + #[dynamic(default = "default_prompt")] + pub prompt: String, +} + +fn default_prompt() -> String { + "> ".to_string() } #[derive(Debug, Clone, PartialEq, FromDynamic, ToDynamic)] diff --git a/wezterm-gui/src/overlay/prompt.rs b/wezterm-gui/src/overlay/prompt.rs index 91ef1ee6940..19debe8ef16 100644 --- a/wezterm-gui/src/overlay/prompt.rs +++ b/wezterm-gui/src/overlay/prompt.rs @@ -67,7 +67,7 @@ pub fn show_line_prompt_overlay( let mut host = PromptHost::new(); let mut editor = LineEditor::new(&mut term); - editor.set_prompt("> "); + editor.set_prompt(&args.prompt); let line = editor.read_line(&mut host)?; promise::spawn::spawn_into_main_thread(async move { From c4ccfb467df1c57473e6d279b33ae0001d8d4165 Mon Sep 17 00:00:00 2001 From: mgpinf Date: Tue, 17 Sep 2024 00:09:24 +0530 Subject: [PATCH 2/3] commit: update documentation for PromptInputLine --- docs/config/lua/keyassignment/PromptInputLine.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/config/lua/keyassignment/PromptInputLine.md b/docs/config/lua/keyassignment/PromptInputLine.md index 49f6d254046..56f6bb2bba6 100644 --- a/docs/config/lua/keyassignment/PromptInputLine.md +++ b/docs/config/lua/keyassignment/PromptInputLine.md @@ -8,7 +8,7 @@ from the user. When the user enters the line, emits an event that allows you to act upon the input. -`PromptInputLine` accepts two fields: +`PromptInputLine` accepts three fields: * `description` - the text to show at the top of the display area. You may embed escape sequences and/or use [wezterm.format](../wezterm/format.md). @@ -18,6 +18,8 @@ upon the input. objects from the current pane and window, and `line` is the text that the user entered. `line` may be `nil` if they hit Escape without entering anything, or CTRL-C to cancel the input. +* `prompt` - the text to show as the prompt. You may embed escape sequences + and/or use [wezterm.format](../wezterm/format.md). Defaults to: `"> "` ## Example of interactively renaming the current tab From 78d8e351e036df0e62dc692751b3393633811d42 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 22 Sep 2024 10:55:46 -0700 Subject: [PATCH 3/3] Update docs/config/lua/keyassignment/PromptInputLine.md --- docs/config/lua/keyassignment/PromptInputLine.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/lua/keyassignment/PromptInputLine.md b/docs/config/lua/keyassignment/PromptInputLine.md index 56f6bb2bba6..904cb6a5ae3 100644 --- a/docs/config/lua/keyassignment/PromptInputLine.md +++ b/docs/config/lua/keyassignment/PromptInputLine.md @@ -19,7 +19,7 @@ upon the input. user entered. `line` may be `nil` if they hit Escape without entering anything, or CTRL-C to cancel the input. * `prompt` - the text to show as the prompt. You may embed escape sequences - and/or use [wezterm.format](../wezterm/format.md). Defaults to: `"> "` + and/or use [wezterm.format](../wezterm/format.md). Defaults to: `"> "`. {{since('nightly', inline=True)}} ## Example of interactively renaming the current tab