Start Windows Terminal in WSL2 home directory

A little tip, partly written for the benefit of future-me…

As you may know, WSL2 filesystem performance is much improved over its predecessor – but only in the virtual disk of your Linux distro. The mounted Windows disk – /mnt/c/ – is still slow for disk-heavy operations, like Git clones, because of Linux-plus-NTFS something reasons.

Because of this, the first thing I do when I open my WSL2 Ubuntu distro in Windows Terminal is change to my Linux home directory. Every time.

There must be an easier way? Yep.

From the WSL docs:

bash ~ launches the bash shell into the user’s home directory. Similar to running cd ~.

To make this the default in Windows Terminal, open the Windows Terminal Settings, find your WSL2 profile, and add “commandline”: “bash.exe ~”

{
    "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}",
    "hidden": false,
    "name": "Ubuntu",
    "source": "Windows.Terminal.Wsl",
    "commandline": "bash.exe ~"
}

(Note that the “source” line now needs a trailing comma.)

From this:

To this:

6 thoughts on “Start Windows Terminal in WSL2 home directory

    1. my setting looks like
      “name”: “Ubuntu”,
      “source”: “Windows.Terminal.Wsl”,
      “startingDirectory”: “//wsl$/Ubuntu/home/”

  1. Thanks for the pointer, Dan!
    I use multiple distributions with WSL (Ubuntu for dev, Debian for test), so I need to launch with wsl.exe -d I found out (wsl –help) that wsl.exe has a parameter to cd after launch. My Windows Terminal commandline is now ‘wsl -d Ubuntu –cd ~’ and the startingDirectory attribute is left blank.

      1. and in my comment above happened the same (the comment system of the blog replaced the double hyphen by a long dash which in a copy and paste will make it fail … just be all advised to replace it 🙂

Leave a Reply to Felipe Portella Cancel reply

Your email address will not be published. Required fields are marked *