Skip to content

Instantly share code, notes, and snippets.

@cedrickring
Last active December 20, 2018 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedrickring/bc60a179a6d92076592dec7e56a88078 to your computer and use it in GitHub Desktop.
Save cedrickring/bc60a179a6d92076592dec7e56a88078 to your computer and use it in GitHub Desktop.
Use zsh instead of bash in WSL

Use zsh instead of bash in WSL

Prerequisites

First of all, you need to install your favorite Windows Subsystem for Linux flavor.
For installation steps, see here

Install zsh

To install zsh, you should follow the steps described here.
I'd recommend installing Oh My Zsh too, since it's a great extension for zsh.

Configure WSL to use zsh instead of bash

  1. After installing zsh, run chsh -s $(which zsh) to switch from bash to zsh
  2. Open the .zshrc in your preferred editor and add cd ~ as the first line
  3. I'd recommend adding symlinks from /mnt/c/Users/<your-username> to ~/<your-username>
    ln -s /mnt/c/Users/<your-username> ~/<your-username>
    
  4. Make sure to use wsl.exe and not bash.exe when opening the WSL terminal again

Configure Hyper.js

For those of you who would like to have a nicer terminal experience than the default Windows command line can install Hyper.

To use Hyper with WSL, you just have to change the shell path in the ~/.hyper.js configuration file

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

Configure VSCode

If you'd like to have the WSL terminal in VSCode you can add the following line to your user settings:

"terminal.integrated.shell.windows": "C:\\Windows\\sysnative\\wsl.exe"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment