Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom prompt for PromptInputLine #6054

Merged
merged 3 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading