reedline icon indicating copy to clipboard operation
reedline copied to clipboard

render right prompt on the last row of the left prompt

Open nibon7 opened this issue 3 years ago • 3 comments

This PR makes nushell+starship behave like other shells (e.g. zsh). Related: starship/starship#3982 Closes nushell/nushell#4909

  • nushell native prompt Screenshot from 2022-10-16 00-06-28
  • nushell + starship(disable line_break and add_newline) Screenshot from 2022-10-16 00-07-09
  • nushell + starship(enable line_break and disable add_newline) Screenshot from 2022-10-16 00-07-51
  • nushell + starship(enable line_break and add_newline) Screenshot from 2022-10-16 00-08-34

nibon7 avatar Oct 15 '22 16:10 nibon7

to me, it's a bit weird to have the left prompt and the right prompt on different lines. My personal preference would be like the middle one in #4909. Is this option available with your change?

starship on  master [$] is 📦 v1.4.2 via 🦀 v1.59.0                             10/16/2022 12:08:15 AM
❯ 

fdncred avatar Oct 15 '22 17:10 fdncred

Is this option available with your change? Nope. This PR always render the right prompt on the last row. Shall we provide an option to render it on the first or the last row?

nibon7 avatar Oct 15 '22 17:10 nibon7

My personal preference would be like the middle one in #4909.

I think you must have disabled add_newline :joy:

nibon7 avatar Oct 15 '22 17:10 nibon7

I have a base implementation to control whether we render the right prompt on the first or last line by setting an environment variable. @fdncred

Screenshot from 2022-10-16 21-11-23

nibon7 avatar Oct 16 '22 13:10 nibon7

it's a beautiful things @nibon7! thanks for considering my request!

fdncred avatar Oct 16 '22 19:10 fdncred

I don't have strong opinions on this one. Will the right prompt still be hidden when the first line is full? Do we need to make this an option?

sholderbach avatar Oct 16 '22 20:10 sholderbach

I do think this should be some configurable option in nushell vs an env var maybe?

fdncred avatar Oct 16 '22 22:10 fdncred

Will the right prompt still be hidden when the first line is full?

In fact, we just calculate the width of the last row, so if there are multiple rows and the last row is not full, it won't be hidden.

https://github.com/nushell/reedline/blob/5061d2288c7ab8373700253ad56127fb8b0b5f73/src/painting/prompt_lines.rs#L95-L118

e.g. (term size).columns is 79, the following code still shows the right prompt.

let-env PROMPT_COMMAND = { "LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLONG_LINE_EATEN\n<PROMPT_INDICATOR>" }
let-env PROMPT_COMMAND_RIGHT = { "RIGHT_PROMPT" }

If there is one line, it will be hidden.

Do we need to make this an option?

I think it's nice to provide an option to let right prompt to override if the line is full.

nibon7 avatar Oct 17 '22 05:10 nibon7

I do think this should be some configurable option in nushell vs an env var maybe?

Agreed, I did this just for a quick test.

nibon7 avatar Oct 17 '22 05:10 nibon7

@sholderbach I think we're ready to land this if you are, as well as https://github.com/nushell/nushell/pull/6781 when ready.

fdncred avatar Oct 20 '22 15:10 fdncred

Let's get this in, I haven't fully validated the last line behavior but that can probably best evaluated with the nushell side with the different prompt configurations.

sholderbach avatar Oct 20 '22 19:10 sholderbach