Set Windows Terminal to use your user HOME directory

Windows Terminal is the new Terminal experience from the Windows team. It’s open source and iterating quickly. As a WSL user, a really nice feature is that it auto-detects the WSL distros you have installed.

By default, when you launch Windows Terminal for a WSL distro it puts you in the /mnt/... path for your Windows user profile (e.g. /mnt/c/Users/stuart).

As this post by Simon Ferquel suggests: “Fully embrace WSL2”! In other words, use the file system in your WSL distro. When you embrace this mindset, having Windows Terminal put you in a mounted Windows path is less helpful - I like to have it default to my HOME directory for the distro.

Fear not! This can be configured in the Windows Terminal settings. Fire up Windows Terminal and press Ctrl+, to open the JSON settings. For each profile you can set a startingDirectory property. There are two things to bear in mind for this property:

  1. The path needs to be a Windows path - so for your HOME folder in WSL you need to use the \\wsl$\... file share
  2. Backslashes need to be escaped, so this becomes \\\\wsl$\\...

To make it easy to get this path you can run the following command from your distro. This will convert the WSL HOME folder path to \\wsl$\... form, escape the backslashes and then pop the result on the clipboard ready for you to paste into your

wslpath -w ~ | sed 's/\\/\\\\/g' | clip.exe

Here’s an example of the finished result:

"profiles": {
    "defaults": {
        // Put settings here that you want to apply to all profiles.
    },
    "list": [
        {
            "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
            "hidden": false,
            "name": "Ubuntu-20.04",
            "source": "Windows.Terminal.Wsl",
            "startingDirectory": "\\\\wsl$\\Ubuntu-20.04\\home\\stuart"
        },

Enjoy!

P.S. If you liked this, you may also like my upcoming book “WSL 2: Tips, Tricks and Techniques” - available for pre-order :-)