mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Add --right-prompt flag to read
Add a flag to read to allow for setting the right prompt command in addition to the existing support for setting the prompt command. Fixes #1698.
This commit is contained in:
parent
b480c8ce79
commit
fe9cf673a2
2 changed files with 13 additions and 1 deletions
12
builtin.cpp
12
builtin.cpp
|
@ -2310,6 +2310,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
|
|||
int i, argc = builtin_count_args(argv);
|
||||
int place = ENV_USER;
|
||||
const wchar_t *prompt = DEFAULT_READ_PROMPT;
|
||||
const wchar_t *right_prompt = L"";
|
||||
const wchar_t *commandline = L"";
|
||||
int exit_res=STATUS_BUILTIN_OK;
|
||||
const wchar_t *mode_name = READ_MODE_NAME;
|
||||
|
@ -2350,6 +2351,10 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
|
|||
L"prompt", required_argument, 0, 'p'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"right-prompt", required_argument, 0, 'R'
|
||||
}
|
||||
,
|
||||
{
|
||||
L"command", required_argument, 0, 'c'
|
||||
}
|
||||
|
@ -2388,7 +2393,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
|
|||
|
||||
int opt = wgetopt_long(argc,
|
||||
argv,
|
||||
L"xglUup:c:hm:n:saz",
|
||||
L"xglUup:R:c:hm:n:saz",
|
||||
long_options,
|
||||
&opt_index);
|
||||
if (opt == -1)
|
||||
|
@ -2431,6 +2436,10 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
|
|||
prompt = woptarg;
|
||||
break;
|
||||
|
||||
case L'R':
|
||||
right_prompt = woptarg;
|
||||
break;
|
||||
|
||||
case L'c':
|
||||
commandline = woptarg;
|
||||
break;
|
||||
|
@ -2556,6 +2565,7 @@ static int builtin_read(parser_t &parser, wchar_t **argv)
|
|||
|
||||
reader_push(mode_name);
|
||||
reader_set_left_prompt(prompt);
|
||||
reader_set_right_prompt(right_prompt);
|
||||
if (shell)
|
||||
{
|
||||
reader_set_complete_function(&complete);
|
||||
|
|
|
@ -23,6 +23,8 @@ The following options are available:
|
|||
|
||||
- `-p PROMPT_CMD` or `--prompt=PROMPT_CMD` uses the output of the shell command `PROMPT_CMD` as the prompt for the interactive mode. The default prompt command is <code>set_color green; echo read; set_color normal; echo "> "</code>.
|
||||
|
||||
- `-R RIGHT_PROMPT_CMD` or `--right-prompt=RIGHT_PROMPT_CMD` uses the output of the shell command `RIGHT_PROMPT_CMD` as the right prompt for the interactive mode. There is no default right prompt command.
|
||||
|
||||
- `-s` or `--shell` enables syntax highlighting, tab completions and command termination suitable for entering shellscript code in the interactive mode.
|
||||
|
||||
- `-u` or `--unexport` prevents the variables from being exported to child processes (default behaviour).
|
||||
|
|
Loading…
Reference in a new issue