Skip to content

Cursor style is overridden when exiting nushell #8452

Closed

Description

@scallaway

Describe the bug

For all my terminals, I have the cursor set to the block-style at all times.

When I enter nushell, the default is to have the cursor in line-style.

However, when I exit nushell, the terminal continues to use the line-style for the cursor in the current session.

I have confirmed this is both the case with Kitty terminal on linux and Windows terminal (with WSL) on Windows 11.

How to reproduce

This is easiest to see when you have a tmux instance open (so you can compare).

  1. Update the config for your terminal to use block-style cursors
  2. Open a session of nushell
  3. Verify that the cursor is line-style (by default)
  4. Exit the session
  5. See that the cursor remains in the line-style

It's worth noting at this point that if you open another tmux session, then the cursor style is as you originally configured (block-style in my case).

Expected behavior

I'd expect the cursor style to not be overridden once you've exited a nushell session.

Screenshots

image

Before booting into a shell

image

inside the shell session

image

outside the session after exit

Configuration

| key                | value                                    |
| ------------------ | ---------------------------------------- |
| version            | 0.77.0                                   |
| branch             | main                                     |
| commit_hash        | fd09609b44b53d41ac7929e90708cdeba7bfb571 |
| build_os           | linux-x86_64                             |
| build_target       | x86_64-unknown-linux-gnu                 |
| rust_version       | rustc 1.66.1 (90743e729 2023-01-10)      |
| rust_channel       | 1.66.1-x86_64-unknown-linux-gnu          |
| cargo_version      | cargo 1.66.1 (ad779e08b 2023-01-10)      |
| build_time         | 2023-03-14 19:46:05 +00:00               |
| build_rust_channel | debug                                    |
| features           | default, zip                             |
| installed_plugins  |                                          |

Additional context

No response

Activity

  1. fdncred commented on Mar 14, 2023

    @fdncred
    Contributor

    You can change your cursor shape in the config file like this

    let-env config = {
    ... other stuff
        cursor_shape: {
            emacs: line # block, underscore, line (line is the default)
            vi_insert: block # block, underscore, line (block is the default)
            vi_normal: underscore # block, underscore, line  (underscore is the default)
        }
    }
    

    Also, if your terminal supports xterm sequences you can follow these rules, outside of nushell, to reset your cursor shape.

    CSI Ps SP q
              Set cursor style (DECSCUSR), VT520.
                Ps = 0  ⇒  blinking block.
                Ps = 1  ⇒  blinking block (default).
                Ps = 2  ⇒  steady block.
                Ps = 3  ⇒  blinking underline.
                Ps = 4  ⇒  steady underline.
                Ps = 5  ⇒  blinking bar, xterm.
                Ps = 6  ⇒  steady bar, xterm.
    

    So, for a steady block you'd type

    echo -e "\033[2 q"
    

    reference

  2. aetherplex commented on Mar 19, 2023

    @aetherplex

    Is it possible to change the default cursor to block?

  3. added
    A:line-editor
    A:configuration
    on Mar 19, 2023
  4. fdncred commented on Mar 20, 2023

    @fdncred
    Contributor

    Is it possible to change the default cursor to block?

    I don't understand @aetherplex, I explained how to change it in the comment above yours. Am I misunderstanding your question?

  5. scallaway commented on Mar 21, 2023

    @scallaway
    Author

    @fdncred

    I think what you've suggested for changing the cursor is perfectly valid, however I think I'd prefer to understand why it's changing the terminal cursor when I'm not in a nushell session.

    Surely any changes that are made inside the session should be reverted when exited?

  6. fdncred commented on Mar 21, 2023

    @fdncred
    Contributor

    @scallaway, my question was directed at @aetherplex.

    Regarding your question about after nushell, maybe you're right. I'm not sure. Cursors are usually controlled by the terminal or the prompt. We're a few versions behind on our crossterm crate, which controls this. I'm not sure if there is a change in it or not. We also could have a bug in reedline or nushell that is causing this. It'll take a dedicated soul to try and figure that out.

    It seems like your terminal is taking a passive approach, meaning that whomever changes the cursor, it will just use that. You could try the echo statement I have above to change it however you see fit. Currently, I think nushell takes the opposite approach, which is to set the cursor no matter what you change it to in the terminal and the only way to change it is to change it in the config.

  7. cassepipe commented on Mar 28, 2023

    @cassepipe

    I encounter the same issue.
    The terminal is not the issue here, it just obeys the commands the line editor gives it I believe.

    If I remember correctly, it is considered good practice for any terminal program to store the state of terminal when it starts and restore that state it as it was before when it exits.

  8. fdncred commented on Mar 28, 2023

    @fdncred
    Contributor

    The terminal is not the issue here, it just obeys the commands the line editor gives it I believe.

    It can work either way but I get your point.

    We'd probably accept a PR to reedline and/or nushell to help with this.

  9. aerique commented on Aug 31, 2023

    @aerique

    I have something similar which may or may not have the same cause: I'm playing around with nushell, trying it out, changing some config options, launching it and exiting it again. This is all from Fish shell. In Fish my cursor is a solid block, in nushell I configured it to be a solid block as well but:

    When I exit nushell to Fish my cursor is a blinking solid block so I run it like this now to reset it to a non-blinking solid block nu ; echo -en '\e[2 q'.

    I do not have this issue with any other programs I launch from Fish, including my own shell I'm developing.

  10. mb21 commented on Sep 7, 2023

    @mb21

    Seems crossterm has now a function to get cursor shape so nushell could use that to restore the cursor before exit?

  11. fdncred commented on Sep 7, 2023

    @fdncred
    Contributor

    I don't see the function. Is it in crossterm or just in someone's fork?

  12. added a commit that references this issue on Sep 9, 2023
  13. fdncred commented on Sep 9, 2023

    @fdncred
    Contributor

    closing since #10289 landed. let's open a new issue if there are still problems.

  14. added this to the v0.85.0 milestone on Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:configurationA:line-editor

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions