Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starship is initialized wrong when loaded by direnv in zsh #860

Closed
hansalves opened this issue Nov 2, 2023 · 5 comments · Fixed by #1370
Closed

Starship is initialized wrong when loaded by direnv in zsh #860

hansalves opened this issue Nov 2, 2023 · 5 comments · Fixed by #1370
Labels
bug Something isn't working

Comments

@hansalves
Copy link

Describe the bug
Starship outputs wrong control characters when initialized from zsh through direnv.
A clear and concise description of what the bug is.

To reproduce
This can be reproduced by creating a .envrc (by running devenv init) in the starship example in git from zsh.

image

The integration adds eval "$(starship init $(echo $0))" to the enterShell.
$0 will be the bash that's started by devenv, not the parent shell. This causes starship to output bash control characters instead of zsh ones.

Version

devenv: 0.6.3

@hansalves hansalves added the bug Something isn't working label Nov 2, 2023
@hansalves
Copy link
Author

A workaround is to set the STARSHIP_SHELL variable to zsh. However, this will cause starships shell module to display zsh instead of bash.

@cyberjar09
Copy link

cyberjar09 commented May 29, 2024

how did youll resolve this? I also have the same problem but the setting of STARSHIP_SHELL did not work

{ pkgs, lib, config, inputs, ... }:

{
  env.STARSHIP_SHELL = "zsh";

  enterShell = ''
    if [ -d ".venv" ]; then
      source .venv/bin/activate
    else
      uv venv && source .venv/bin/activate
    fi
  '';


  languages = {
    python = {
      enable = true;
      version = "3.11.6";
    };
  };


  dotenv.enable = true;

  starship.enable = true;
}

for context, I already use starship on my laptop. When I cd into the project directory, the shell shows the mangle of chars as in the screenshot above. But when I devenv shell its normal again.

@hansalves
Copy link
Author

hansalves commented May 29, 2024

I ended up not using starship from devenv, but initializing it from my .bashrc / .zshrc
In devenv I now only have

    enterShell = ''
        export STARSHIP_CONFIG=${config.env.DEVENV_ROOT}/starship.toml
    .......
    ''

@therealpxc
Copy link
Contributor

This affects me with Fish as well:

image

@therealpxc
Copy link
Contributor

I've also noticed that the prompt gets mangled if I just call bash in there, but not if I invoke the systemwide bash provided by Nix. I think we've ended up with pkgs.bash rather than pkgs.bashInteractive. When I add pkgs.bashInteractive to my packages declaration in devenv.nix, my prompt looks fine when I enter a new shell with bash.

I think we can maybe fix this if we get mkShell or something similar to use bashInteractive instead of plain bash. The WIP devShellTools.buildShell might solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants