An very easy and safe way to change template's default shell from bash to zsh for root and user

Bash lacks support for autosuggestions and syntax highlighting.Fish is great, but its incompatibility with Bash syntax leads to some compatibility issues.Zsh is the only option left.

The whonix template come with a default zsh config and it work in other distro too.So you don’t have to install OhMyZsh or anything else in your template.

  1. apt install zsh-autosuggestions zsh-common zsh or dnf install zsh zsh-autosuggestions zsh-syntax-highlighting
  2. cd to /etc/zsh/ in whonix-gateway template and delete /etc/zsh/zshrc and /etc/zsh/zprofile otherwise copy to other vm wil fail.
  3. Copy /etc/zsh/ from whonix-gateway template to fedora/debian templete and replace the original /etc/zsh if exists.
  4. In debian, run
ln -s /etc/zsh/zprofile.dist /etc/zsh/zprofile
ln -s /etc/zsh/zshrc.dist /etc/zsh/zshrc
  1. In fedora, run
rm /etc/zshrc /etc/zprofile
ln -s /etc/zsh/zprofile.dist /etc/zprofile
ln -s /etc/zsh/zshrc.dist /etc/zshrc
  1. Change shell
sudo chsh -s /usr/bin/zsh user
sudo chsh -s /usr/bin/zsh
  1. Create empty ~/.zshrc in template’s. For the appvm that already create, just select 0 when you first launch zsh.

Now you can use zsh everywhere with autosuggestions and syntax-highlighting

6 Likes

Thank you for posting this :smiley:

As a fish user, it’s not really a problem

  • bash scripts are running with bash due to the shebang, everything is fine here
  • small one liners are easy to create in fish, low learning curve
  • for complex bash snippets, just type bash in the shell to switch for it
1 Like

Yeah, but there are still scripts that are not compatible with fish. For example, the bash-implemented golang multi-version manager gvm hasn’t been adapted for fish. Although running it with fish’s bash compatibility plugin works for most functions, it can not switch golang versions when using fish. Plus, many tutorials don’t provide fish commands, so in the end, I decided to switch to zsh.