Moving From Zsh to Fish Shell in Nixos Darwin
I was using ZSH with OmhZH for a long time now, but for the last couple of months I was starting to feel ZSH to be slow, like palpably slow.
Then I came across this post on HackerNews about OmhZH, where, looking at the comments, I realised it’s not actually ZSH that is slow, but it’s actually OmgZH that makes ZSH slow with all the bloat that it adds.
I don’t use all the functionality of OmgZH; I mainly rely on autocomplete by checking the history and file names of the path that I am in. So after looking at more comments on the HackerNews post, I saw that Fish provides autocomplete out of the box and looks good.
So I decided to change from ZSH and OmgZH to fish within my NixOS dawrin installation, and it looked exactly like my ZSH after everything was done.
Install Fish #
Installing Fish is relatively easy; all you need to do is add Fish to your nix configuration.
configuration = { pkgs, ... }: {
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages =
[
...
pkgs.fish
pkgs.starship
...
];
# Enable alternative shell support in nix-darwin.
programs.fish.enable = true;
And enable fish as an alternative shell by setting programs.fish.enable = true;
your Nix configuration.
Install Starship for a nicer prompt #
Even with ZSH, I was using StarShip as my prompt; it was easy to install and customise, and I like the look and feel of it.
As you see, I have already installed Starship using my Nix configuration file.
After installing fish, all your fish configuration can be found in the ~/.config/fish/config.fish
file. So open your editor and add the following line to the end of the file.
starship init fish | source
This would automatically launch Starship as your prompt when you open Fish.
And once your NixOS configuration file is ready, build your NixOS by running the following command, which will install Starship and Fish.
nix run nix-darwin/nix-darwin-25.05#darwin-rebuild --extra-experimental-features "nix-command flakes" -- switch --flake ~/.config/nix --show-trace;
Launch Fish when you open your terminal #
I am using Wezterm as my current terminal, and even with the programs.fish.enable = true;
Wezterm did not launch Fish when I open a new terminal instance.
Therefore, I had to modify the Wezterm configuration to make sure it launches Fish when a new terminal instance is initiated.
if fs.platform().is_mac then
Config.default_prog = {
"/run/current-system/sw/bin/fish", "-l", "-i"
}
end
This would look whether my system is macOS and then trigger fish. The path for fish may differ from system to system; this is the path where Wish was installed by NixOS Darwin.
If you would like to find where Fish was installed, you can use which fish
to find the path to your Fish installation.
Also, the way to configure fish may differ from terminal to terminal. I just shared how I did it with Wezterm, but you can check the documentation of your favourite terminal to find out how you can change your shell to Fish.
And just like that, everything was back to how I had it from ZSH. I have autocomplete already implemented out of the box by Fish, and the look feels the same with StarShip. And I don’t feel the palpable slowness anymore.