cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.71k stars 274 forks source link

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

Open hansalves opened 8 months ago

hansalves commented 8 months ago

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 commented 5 months ago

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 commented 1 month ago

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 commented 1 month ago

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
    .......
    ''