Skip to content

Commit

Permalink
Custom prompt for PromptInputLine (#6054)
Browse files Browse the repository at this point in the history
* option to configure PromptInputLine prompt

- Introduces an option to set custom prompt text
- If 'prompt' not passed in parameters, default value of "> " used

* commit: update documentation for PromptInputLine

* Update docs/config/lua/keyassignment/PromptInputLine.md

---------

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
  • Loading branch information
mgpinf and wez authored Sep 22, 2024
1 parent 5a594f5 commit 6a12dd1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config/src/keyassignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 3 additions & 1 deletion docs/config/lua/keyassignment/PromptInputLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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: `"> "`. {{since('nightly', inline=True)}}

## Example of interactively renaming the current tab

Expand Down
2 changes: 1 addition & 1 deletion wezterm-gui/src/overlay/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6a12dd1

Please sign in to comment.