DEV Community

loading...

Adding MSL Shell to Windows Terminal

ganesshkumar profile image Ganessh Kumar Originally published at ganesshkumar.com ・2 min read

After installing any flavors of Linux using Windows Subsystem for Linux, WSL, on Windows 10, you open Microsoft's latest Windows Terminal and do not find your linux shell in it?

Then this guide is for you.

  • Make sure you have installed your desired version of Linux from the Windows Store.

Ubuntu-18.04

  • In Windows Terminal click the dropdown icon and select settings. Alternatively, you can open it with Ctrl + , shortcut. This will open profiles.json file in your text editor

Terminal

  • In the profiles.json file, find the profiles section. profiles is an array where each element in the array maps to a shell (powershell or cmd or any linux shell)
    "profiles" : 
    [
        {
            "acrylicOpacity" : 0.5,
            "background" : "#012456",
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "powershell.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
            "name" : "Windows PowerShell",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : false
        },
        {
            "acrylicOpacity" : 0.75,
            "closeOnExit" : true,
            "colorScheme" : "Campbell",
            "commandline" : "cmd.exe",
            "cursorColor" : "#FFFFFF",
            "cursorShape" : "bar",
            "fontFace" : "Consolas",
            "fontSize" : 10,
            "guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
            "historySize" : 9001,
            "icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
            "name" : "cmd",
            "padding" : "0, 0, 0, 0",
            "snapOnInput" : true,
            "startingDirectory" : "%USERPROFILE%",
            "useAcrylic" : true
        }
    ],
  • Add an entry in this array for your linux shell. To populate this, you need the following values
    • Command to start your shell
      • To get list of WSL shells run the command wsl.exe --list
      • To start a particular WSL shell run wsl.exe -d <shell_name_from_above>
      • To set the home directory as default directory add ~ to the wsl.exe command
      • Our command to start Ubuntu-18.04 is wsl.exe ~ -d Ubuntu-18.04
    • A new GUID (unique id in this array)
      • A random GUID can be generated from the linux shell by running uuidgen command
      • Replace <guid> in the below snippet with your new GUID (leave the paranthesis intact)
    • Name and icon for the entry
      • Give an identifiable name like Ubuntu-18.04
      • For icon, you can give any file system path in the system. I am opting to use the default linux penguine logo that has been packaged along with the Windows Terminal. Hence, I set ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png as my icon path.
        {
            "acrylicOpacity":0.75,
            "closeOnExit":true,
            "colorScheme":"Campbell",
            "commandline":"wsl.exe ~ -d Ubuntu-18.04",
            "cursorColor":"#FFFFFF",
            "cursorShape":"bar",
            "fontFace":"Consolas",
            "fontSize":12,
            "guid":"{<guid>}",
            "historySize":9001,
            "icon" : "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
            "name":"Ubuntu-18.04",
            "padding":"0, 0, 0, 0",
            "snapOnInput":true,
            "startingDirectory":"%USERPROFILE%",
            "useAcrylic":true
        }

  • As soon as you save the profiles.json file, the changes will be picked up by the Windows Terminal and you can see your WSL shell.

Ubuntu in Terminal

  • Start a shell and start configuring it. I have configure my shell to be zsh shell with oh-my-zsh extension.

zsh in terminal

Discussion (5)

Collapse
morensya93 profile image
Faisal Morensya

Hi Ganessh, nice stuff man.

I have set up my windows using cygwin and zsh. Now how do i added this to my windows terminal?
this is my setup now, but new zsh is not added to the Windows Terminal

"profiles": {
        "defaults": {
            // Put settings here that you want to apply to all profiles.
        },
        "list": [{
                // other cli here
            ...,              
            {
                "guid": "{d0299d37-cdfb-4222-917b-df79328d786b}",
                "hidden": false,
                "name": "zsh",
                "source": " C://cygwin64/bin/zsh -l -i"
            }
        ]
    },
Collapse
ganesshkumar profile image
Ganessh Kumar Author

Could the double slash after C: might be the cause? Have you tried with C:/cygwin64/bin/zsh -l -i?

Collapse
morensya93 profile image
Faisal Morensya • Edited

It did not work.
The thing is the new terminal menu under new tab not showing.
Im using your json config also not working.

Your Profiles object also different from mine.

Thread Thread
ganesshkumar profile image
Ganessh Kumar Author

github.com/microsoft/terminal/blob...

Both the formats are valid according to their documentation.

Thread Thread
morensya93 profile image
Faisal Morensya

Hi Ganessh,
Its been a while, below json configuration worked for me, thanks for the post, keep it up man!

{
    "closeOnExit" : true,
    "colorScheme" : "Campbell",
    "commandline" : "C:/cygwin64/bin/zsh -l -i",
    "cursorColor" : "#085336",
    "cursorShape" : "vintage",
    "fontSize" : 9,
    "guid": "{d0299d37-cdfb-4222-917b-df79328d786b}",
    "historySize" : 9001,
    "icon" : "C:/cygwin64/Cygwin-Terminal.ico",
    "name" : "Cygwin",
    "snapOnInput" : true,
    "useAcrylic" : true
}
Forem Open with the Forem app