Skip to content

feat(shell): support for Fish on Windows#4775

Open
fstanis wants to merge 1 commit intoprefix-dev:mainfrom
fstanis:windows-shells
Open

feat(shell): support for Fish on Windows#4775
fstanis wants to merge 1 commit intoprefix-dev:mainfrom
fstanis:windows-shells

Conversation

@fstanis
Copy link
Copy Markdown
Contributor

@fstanis fstanis commented Oct 16, 2025

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 exec for fish to "take over" the bash process, sourcing env_file in the process.
  • If we're using bash, we simply source the file with env_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.

@fstanis fstanis changed the title Add support for Fish on Windows feat: support for Fish on Windows Oct 16, 2025
@fstanis fstanis force-pushed the windows-shells branch 2 times, most recently from d62d61b to 57c0946 Compare October 17, 2025 20:49
command.arg("--init-file");
command.arg(&temp_path);
command.arg(&init_file_path);
command.arg("-i");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if you could leave the bash --init-file logic the same as before, and switch this -i into -c fish -i when the shell is fish?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that initially and, unfortunately, it didn't work. While fish inherits the environment variables from the parent bash, it can't inherit the functions (i.e. prompt and completions) because those are shell-specific. So either that would start fish without the prompt or shell completion (if we always use those for bash regardless of shell) or would fail completely (because fish function syntax is incompatible with bash).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, we could probably just skip completions and prompt for zsh for now (or for fish as well, if we want to make this code simpler) and possibly tell the user how to add these manually by editing their .zshrc / config.fish.

@lucascolley lucascolley added cli Issue related to CLI windows Related to MS Windows labels Oct 29, 2025
@lucascolley lucascolley changed the title feat: support for Fish on Windows feat(shell): support for Fish on Windows Oct 29, 2025
@lucascolley lucascolley added enhancement New features area:shell Related to pixi shell labels Oct 29, 2025
@fstanis
Copy link
Copy Markdown
Contributor Author

fstanis commented Nov 6, 2025

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

@baszalmstra
Copy link
Copy Markdown
Contributor

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?

@fstanis
Copy link
Copy Markdown
Contributor Author

fstanis commented Dec 16, 2025

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.

@fstanis fstanis force-pushed the windows-shells branch 2 times, most recently from 7a20c54 to 41f33d0 Compare December 18, 2025 10:24
@fstanis
Copy link
Copy Markdown
Contributor Author

fstanis commented Dec 28, 2025

friendly ping

@ruben-arts
Copy link
Copy Markdown
Contributor

@baszalmstra could you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:shell Related to pixi shell cli Issue related to CLI enhancement New features windows Related to MS Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pixi shell with fish and Windows

5 participants