Starship is initialized wrong when loaded by direnv in zsh
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.
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
A workaround is to set the STARSHIP_SHELL variable to zsh. However, this will cause starships shell module to display zsh instead of bash.
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.
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
.......
''
This affects me with Fish as well:
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.