commandline set-prompt for core
Signature
> commandline set-prompt {flags} (prompt)
Flags
--right, -r {string}: Text for the right prompt, i.e.$env.PROMPT_COMMAND_RIGHT.--indicator, -i {string}: Text for the prompt indicator in the default/emacs edit mode, i.e.$env.PROMPT_INDICATOR.--vi-insert {string}: Text for the prompt indicator in vi insert mode, i.e.$env.PROMPT_INDICATOR_VI_INSERT.--vi-normal {string}: Text for the prompt indicator in vi normal mode, i.e.$env.PROMPT_INDICATOR_VI_NORMAL.--multiline, -m {string}: Text for the multiline continuation indicator, i.e.$env.PROMPT_MULTILINE_INDICATOR.
Parameters
prompt: The rendered prompt text to display, i.e.$env.PROMPT_COMMAND. If left-out, we read from pipeline input.
Input/output types:
| input | output |
|---|---|
| nothing | nothing |
| string | nothing |
Examples
Replace the left prompt with a freshly rendered string.
> job spawn { sleep 1sec; commandline set-prompt $"(ansi green)me> (ansi reset)" }Replace the right prompt.
> job spawn { sleep 1sec; commandline set-prompt --right $"right (date now | format date '%H:%M:%S')" }Replace the default/emacs indicator.
> job spawn { sleep 1sec; commandline set-prompt --indicator $" (char prompt)" }Replace the vi insert and normal mode indicators independently.
> job spawn { sleep 1sec; commandline set-prompt --vi-insert ": " --vi-normal "n " }Replace the multiline continuation indicator.
> job spawn { sleep 1sec; commandline set-prompt --multiline "... " }Replace multiple prompt segments in one call.
> job spawn { sleep 1sec; commandline set-prompt --right "67" --indicator "69" }Stream a slow prompt segment in from a background job.
> job spawn { sleep 1sec; commandline set-prompt $"(git branch --show-current) > " }Notes
This is meant to be called from a background job (see job spawn) to build streaming prompts: we render the prompt as we know it up front, and each commandline set-prompt updates our idea of what the prompt "is" for the segments that have finished computing. The line and cursor are preserved.
--indicator sets only the default/emacs indicator. Use --vi-insert and --vi-normal to set the vi mode indicators independently.
The pushed prompt lasts only until the next prompt is drawn.
meant for REPL sessions only