nushell / nushell/nushell

Removing or hiding the `PROMPT_COMMAND_RIGHT` and `PROMPT_MULTILINE_INDICATOR` should remove the prompt and indicator

Open
#9,923 11 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:configuration status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

I thought about filing this a long time ago, but I'm finally getting around to it because its behavior is a contributing factor to the issue I'm going to open right after this one.

I'm aware that this behavior is (a) probably more of a change for Reedline, but the configuration for these items does (and should) take place in Nu itself. Also (b) this may be "as designed", in which case feel free to convert it to a feature request or close it.


Hiding or removing $env.PROMPT_COMMAND_RIGHT and $env.PROMPT_MULTILINE_INDICATOR should be sufficient for removing those elements, but it isn't, since they are both configured via environment variables and hard-coded into (I believe) Reedline.

In general, I believe that configuration variables that are not crucial to smooth operation of the shell should not have hard-coded defaults, so that they can be more easily removed. As an example of an item that is crucial to the smooth operation of the shell, the left-counterepart, $env.PROMPT_COMMAND might fit. But at least the $ENV.PROMPT_INDICATOR needs a hard-coded default, as found in every shell.

How to reproduce
config env

Comment out or delete $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } and $env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } and restart the shell.

Result: That pesky right prompt and multi-line indicator are still there ;-)

I say that a bit tongue-in-cheek, but the right-prompt and multiline indicator are common pitfalls for me when copying multi-line input or output from the terminal.

I'm fine with the design choice to have them, but since they are defined by env.nu, it should be easier to get rid of them.

For a new user to remove them can be more than a bit frustrating. Let's walk through the process:

  1. Best case, they are going to read the doc and figure out that they need to edit env.nu, preferably using config nu (and after setting the EDITOR and VISUAL that's going to allow them to do that). No complaints there.

  2. Then they are going to see def create_right_prompt right at the top. Oh - That must be what I need to change! Maybe that would work, if the following line wasn't commented out in the current default configuration:

    # $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }
    

    That's part of the issue I'll open next. ;-)

  3. But then they need to get rid of multiline, so they'll need to head down a bit further and find:

    $env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt }  # Assuming the related bug is fixed
    $env.PROMPT_MULTILINE_INDICATOR = {|| "::: " }
    

    Natural assumption is to simply remove or comment out these lines, but that won't work because the hardcoded Reedline version will then take over.

  4. Eventually they have to figure out that these have to be overridden, not removed:

    $env.PROMPT_COMMAND_RIGHT = ""
    $env.PROMPT_MULTILINE_INDICATOR = ""
    

Whew ;-)

Expected behavior

Remove the right prompt and multiline indicator when removing or hiding the corresponding environment variables.

Most importantly, this does not change any existing functionality in Nushell as long as the user chooses to populate env.nu with defaults when prompted. It's also:

  • easier
  • more intuitive
  • more aligned with traditional shell behavior
Screenshots

No response

Configuration
key value
version 0.83.1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.71.0 (8ede3aae2 2023-07-12)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.71.0 (cfd3bbd8f 2023-06-08)
build_time 2023-07-31 18:55:46 -04:00
build_rust_channel release
allocator standard
features dataframe, default, extra, sqlite, trash, which, zip
installed_plugins
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the default environment configuration in env.nu and the Reedline prompt handling described in the report; reproduce the behavior with config env after removing the two variables. Trace where the hard-coded right prompt and multiline indicator are selected. Done means removing or hiding those variables removes both elements without changing populated defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, shell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.