Set ZSH as your default shell in WSL the correct way

TL;DR - Do not use the old bashrc patch. Use chsh and update your launch paths to wsl.exe instead of bash.exe. I have confirmed this working on Debian Stretch and Ubuntu Xenial.

The original workaround

Until recently, there was no way to correctly switch from bash to zsh or fish when running Windows Subsystem for Linux on Windows 10. There were well documented workarounds posted. The most popular of which was to modify the ~/.bashrc to launch zsh instead.

# Launch Zsh
if [ -t 1 ]; then
  exec zsh
fi

This was because the only WSL launcher at the time in the System32 folder was bash.exe and there was no other choice. Well that has all changed with the Spring 2018 Windows 10 update.

The correct way

Since the Spring 2018 Creators Update for Windows 10, you can how use chsh like you would on any other *nix system.

chsh -s $(which zsh)

Now the only change you have to make is find your preferred launcher and change the shortcut from bash.exe to C:\Windows\System32\wsl.exe.

Errors with nice background processing

After switching to ZSH, each time I opened a new shell I would be greated with a not-so-friendly list of errors.

__load__:47: nice(5) failed: operation not permitted
__load__:47: nice(5) failed: operation not permitted
__load__:47: nice(5) failed: operation not permitted
__load__:47: nice(5) failed: operation not permitted

This issue is being tracked here and the workaround is to tell ZSH not to use nice to background tasks.

Add this to your zsh configuration: unsetopt BG_NICE

Hyper users

I do not personally use Hyper.js, but for those that do. Edit your config to launch wsl.exe:

{
  shell: 'C:\\Windows\\System32\\wsl.exe',
  shellArgs: [],
}

Thanks to this post for passing this along.