feat(shell): support for Fish on Windows
This PR fixes #4648.
Currently, on Windows (via #3981) we launch bash by creating a new bash process with --init-file which contains all the environment variables, completions and custom prompt.
This doesn't work for other shells unfortunately since --init-file is bash-specific. This PR splits the init file into two parts: one for the environment variables (called init_file in code), which uses bash syntax, and the other one for completions and custom prompt, which is specific to the shell that's starting (called env_file in code).
pixi shell therefore first starts bash in a new process with the init_file, then one of two things happens:
- If we're using fish, we use
execfor fish to "take over" the bash process, sourcingenv_filein the process. - If we're using bash, we simply
sourcethe file withenv_file.
This logic should be possible to reuse for xonsh and zsh as well, although someone more knowledgeable would need to clarify how to best perform the "take over" step for those shells.
Hey @ruben-arts / @baszalmstra, just a friendly ping since it's been a few weeks, would appreciate your input if you're happy we proceed with this approach
Im trying to test your changes but Im having a hard time installing fish. Could you maybe help me out? I have git bash, but how can I get fish in there as well?
Sure - you need to install pacman first if you're using Git for Windows, I use the script here: https://github.com/alexsarmiento/gitportable-pacman/blob/master/install-pacman-git-bash.sh
After that, pacman -S fish works. Alternatively, if you installed MSYS2 from their website, it comes with pacman already.