mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-26 02:51:16 -03:00
Rework how the mode is reported in fish_vi_mode
Add a new function fish_mode_prompt which (if it is defined) has its output prepended to the left prompt. Rather than replacing the prompt wholesale, make fish_vi_mode enable this function by setting a variable __fish_vi_mode. This enables vi mode to interoperate nicely with custom prompts. Users who want to change how the mode is reported can either redefine this function or erase it entirely. Fixes #1988.
This commit is contained in:
16
reader.cpp
16
reader.cpp
@@ -128,6 +128,10 @@ commence.
|
||||
#define RIGHT_PROMPT_FUNCTION_NAME L"fish_right_prompt"
|
||||
|
||||
|
||||
/* The name of the function for getting the input mode indicator */
|
||||
#define MODE_PROMPT_FUNCTION_NAME L"fish_mode_prompt"
|
||||
|
||||
|
||||
/**
|
||||
The default title for the reader. This is used by reader_readline.
|
||||
*/
|
||||
@@ -997,6 +1001,18 @@ static void exec_prompt()
|
||||
{
|
||||
proc_push_interactive(0);
|
||||
|
||||
// Prepend any mode indicator to the left prompt (#1988)
|
||||
if (function_exists(MODE_PROMPT_FUNCTION_NAME))
|
||||
{
|
||||
wcstring_list_t mode_indicator_list;
|
||||
exec_subshell(MODE_PROMPT_FUNCTION_NAME, mode_indicator_list, apply_exit_status);
|
||||
// We do not support multiple lines in the mode indicator, so just concatenate all of them
|
||||
for (size_t i = 0; i < mode_indicator_list.size(); i++)
|
||||
{
|
||||
data->left_prompt_buff += mode_indicator_list.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
if (! data->left_prompt.empty())
|
||||
{
|
||||
wcstring_list_t prompt_list;
|
||||
|
||||
Reference in New Issue
Block a user