chisui / zsh-nix-shell

zsh plugin that lets you use zsh in nix-shell shells.
BSD 3-Clause "New" or "Revised" License
373 stars 19 forks source link

broken prompt in nested nix-shell with starship #22

Closed lovesegfault closed 4 years ago

lovesegfault commented 4 years ago

Issue description

When nesting nix-shell's I find that this breaks my prompt (starship).

~
viins ❯ nix-shell -p hello
~ via ❄️  shell (impure)
viins ❯ hello
Hello, world!
~ via ❄️  shell (impure)
viins ❯ nix-shell -p hello
\[\]~\[\] via \[\]❄️  \[\]\[\]shell (impure)\[\]
\[\]viins\[\] \[\]❯\[\] hello
Hello, world!
\[\]~\[\] via \[\]❄️  \[\]\[\]shell (impure)\[\]
\[\]viins\[\] \[\]❯\[\]

Steps to reproduce

  1. nix-shell -p hello
  2. See that it works fine
  3. nix-shell -p hello
  4. Weird prompt

Technical details

Please run the following commands and paste the results:

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.47, NixOS, 20.09pre-git (Nightingale)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.6`
 - nixpkgs: `/run/current-system/nixpkgs`
  1. zsh 5.8 (x86_64-pc-linux-gnu)
chisui commented 4 years ago

How did you install starship?

If I simply call eval "$(starship init zsh)" then I get your behavior (since the inner zsh doesn't init starship), but if I add the line too my .zshrc it works fine.

This also happens if I directly create a new shell from within starship with the first way, so I would guess that this is actually a problem with your installation rather then the plugin.

Does the behavior also occur if you simply call zsh again?

lovesegfault commented 4 years ago

How did you install starship?

I use home-manager, here's my config: https://github.com/lovesegfault/nix-config/blob/master/users/bemeurer/core/starship.nix

If I simply call eval "$(starship init zsh)" then I get your behavior (since the inner zsh doesn't init starship), but if I add the line too my .zshrc it works fine.

In my .zshrc I see this:

if [ -z "$INSIDE_EMACS" ]; then
  eval "$(/nix/store/wdjk1q2ckk2wa8vg9macwwn8vl4nna1m-starship-0.43.0/bin/starship init zsh)"
fi

Does the behavior also occur if you simply call zsh again? Nope! If I manually run zsh inside the broken shell I get a non-broken shell

chisui commented 4 years ago

I still think it's an issue of the way starship is installed.


Unfortunately I don't use home-manager, so trying to reproduce this issue would be quite hard on my system. Other, more conventional prompts work fine as far as I can tell.

Since the first level works and it seems to only affect starship I give this issue a very low priority. I will leave the issue open though.