mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-23 10:50:49 +00:00
Shell: Allow the user to set the prompt using PROMPT()
This allows the prompt to be dynamically configurable, making it possible to display various bits of information in the prompt.
This commit is contained in:
parent
71ddc33fbf
commit
84777fbe62
Notes:
sideshowbarker
2024-07-17 06:28:38 +09:00
Author: https://github.com/alimpfard
Commit: 84777fbe62
Pull-request: https://github.com/SerenityOS/serenity/pull/20931
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 45 additions and 1 deletions
|
@ -1967,6 +1967,28 @@ ErrorOr<int> Shell::builtin_run_with_env(Main::Arguments arguments)
|
|||
return exit_code;
|
||||
}
|
||||
|
||||
ErrorOr<int> Shell::builtin_shell_set_active_prompt(Main::Arguments arguments)
|
||||
{
|
||||
StringView new_prompt;
|
||||
|
||||
Core::ArgsParser parser;
|
||||
parser.add_positional_argument(new_prompt, "New prompt text", "prompt", Core::ArgsParser::Required::Yes);
|
||||
|
||||
if (!parser.parse(arguments, Core::ArgsParser::FailureBehavior::Ignore))
|
||||
return 1;
|
||||
|
||||
if (!m_editor) {
|
||||
warnln("shell_set_active_prompt: No active prompt");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (m_editor->is_editing())
|
||||
m_editor->set_prompt(new_prompt);
|
||||
else
|
||||
m_next_scheduled_prompt_text = new_prompt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Shell::has_builtin(StringView name) const
|
||||
{
|
||||
if (name == ":"sv || (m_in_posix_mode && name == "."sv))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue