mirror of
https://github.com/nushell/nushell.git
synced 2024-11-26 10:23:52 +01:00
414216edfa
## Description This PR uses environment variables to enable and set a transient prompt, which lets you draw a different prompt once you've entered a command and you've moved on to the next line. This is useful if you have a fancy two-line prompt with a bunch of info about time and git status that you don't really need in your scrollback buffer. Here's a screenshot. You can see how my usual prompt has two lines and would take up a lot more space if every past command also used the full prompt, but reducing past prompts to `🚀` or `>` makes it take up less space. ![image](https://github.com/nushell/nushell/assets/45539777/dde8d0f5-f95f-4529-9a14-b7919bd51126) I added the following lines to my `env.nu` to get that rocket as the prompt initially: ```nu $env.TRANSIENT_PROMPT_COMMAND = {|| "" } $env.TRANSIENT_PROMPT_INDICATOR = {|| open --raw "~/.prompt-indicator" } $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = $env.TRANSIENT_PROMPT_INDICATOR ``` ## User-Facing Changes If you want to change a segment of the prompt, set the corresponding `TRANSIENT_PROMPT_*` variable. <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> ## Problems/Things to Consider: - The transient prompt clones the `Stack` at the very beginning of the session and keeps that around. I'm not sure if that could cause problems, but if so, it could probably take an `Arc<State>` instead. - This isn't truly a problem, but now there's even more environment variables, which is kinda annoying. - There might be some performance issues with creating a new `NushellPrompt` object and cloning the `Stack` for every segment of the transient prompt. What's more, the transient prompt is added to the `Reedline` object whether or not the user has enabled transient prompt, so if there are indeed performance issues, simply disabling the transient prompt won't help. - Perhaps instead of a separate `TRANSIENT_PROMPT_INDICATOR_VI_INSERT` and `TRANSIENT_PROMPT_INDICATOR_VI_NORMAL`, `TRANSIENT_PROMPT_INDICATOR` could be used for both (if it exists). Insert and normal mode don't really matter for previously entered commands. |
||
---|---|---|
.. | ||
src | ||
.gitignore | ||
Cargo.toml | ||
LICENSE |