Microsoft recently released a new terminal application called Windows Terminal. The terminal application has a lot of features that the developers have been asking for years. One of those features is that ability to add any console window to a new tab. Let me show you how to add Ubuntu tab to the Windows Terminal.
By default, Windows Terminal comes with PowerShell and Command Prompt tabs. If you want to, you can add any number of other consols to the Windows Terminal. For example, if you are a web developer and need to add a Linux console to Windows Terminal. You can do that by adding a few lines of code in a JSON file.
Note: I assume you’ve already installed the new Windows Terminal app. If not, you can install it from the Microsoft Store.
Add Ubuntu Tab to Windows Terminal
1. Make sure that you’ve installed Ubuntu in Windows 10. If not, you can install Ubuntu in Windows 10 with just a few clicks. Follow that Ubuntu installation guide and come here next.
2. Before you can add Ubuntu tab to Windows Terminal, you need to generate a new GUID (Globally Unique Identifier). This is how Windows Terminal differentiates between different consols. To generate a new GUID, search for Ubuntu in the start menu and open it.
3. In the Ubuntu window, execute the uuidgen
command. This will give a unique GUID, copy it. We are going to need that GUID in the coming steps. So, paste it somewhere safe.
A quick tip: Select the GUID with the mouse and right-click to copy.
4. Now, open Windows Terminal by searching for it in the start menu.
5. In the Terminal window, click on the dropdown icon and select “Settings”.
6. The above action will open the profiles.json file in your default code editor. In my case, the default code editor is VS Code. In the editor, scroll down until you see the Profiles array. At the end of the array add ,
.
7. Next, copy and paste the below code under the ,
while replacing YOUR_GUID with the actual GUID you got in step 3.
Note: If you’ve installed a specific version of Ubuntu then modify the 5th line in the below code and add the version number too. For example, if you’ve installed Ubuntu 18.04, modify the line as wsl.exe -d Ubuntu-18.04
.
{ "acrylicOpacity":0.75, "closeOnExit":true, "colorScheme":"Campbell", "commandline":"wsl.exe -d Ubuntu", "cursorColor":"#FFFFFF", "cursorShape":"bar", "fontFace":"Consolas", "fontSize":12, "guid":"{YOUR_GUID}", "historySize":9001, "icon":"C:/Dummy/image.png", "name":"Ubuntu", "padding":"0, 0, 0, 0", "snapOnInput":true, "startingDirectory":"%USERPROFILE%", "useAcrylic":true }
8. Press Ctrl + S to save the JSON file.
9. Now, go back to the Windows Terminal and click on the dropdown menu. You will see the new Ubuntu option.
10. Click on the Ubuntu option and the Ubuntu terminal will open in Windows Terminal.
Add Custom Tab Icon to Ubuntu Tab in Windows Terminal
If you look at the dropdown menu, there is no icon next to the Ubuntu option. That’s because you haven’t added any. The good thing is, you can any image you want as the Ubuntu tab icon.
1. The first thing you need to do is find the icon you want to set. The icon should be in PNG format with transparent background and 32×32 size. You can use this website to find free icons.
2. Once you have the icon, save it somewhere on your hard disk. For instance, I have a dedicated folder in my I drive that hosts all the icons I use for various folders.
3. Now, open the profiles.json file, go to the Ubuntu profile, find the “icon” value and replace the dummy icon path with the actual icon path. In my case, the icon path is “I:/System Icons/ubuntu.png”.
4. Save the file.
That is it. You will see the new icon applied instantly in the Windows Terminal.
It is that simple to add Ubuntu tab to Windows Terminal. If you are facing any problems, comment below and I will try to help as much as possible.
Thanks, exactly what I was looking for !
I’m glad the article helped you. Have a nice day.
What would I have to put in startingDIrectory so it starts on my linux home?
Nevermind, apparently this is an issue they are dealing with, and a good workaround is to use “wsl.exe ~ -d Distro”, so it will start at home dir.
By the way, your article was super helpful, thanks!
I’m glad the article helped you.
I think you can also set startingDirectory to
//wsl$/Ubuntu/home/username
to start in the home directory. Give it a try.Nope, it just goes to /mnt/c/Users/username. Not the user home in Ubuntu or whatever distro you have from the store.
Been trying to figure this out other than a long path to the package directory in APPDATA
I’ve solved it doing what David mentioned at the beginning of this sub-thread. Basically in the commandline value, you need to pass ~ as an argument to wsl.exe. Once you do that, whatever value you put in startingDirectory will be irrelevant. This works for me.
So to recap:
“commandline”: ““wsl.exe ~ -d Distro”, // note the “~”
“startingDirectory”: “/whatever/it/wont/make/a/difference”
> Nevermind, apparently this is an issue they are dealing with, and a good workaround is to use “wsl.exe ~ -d Distro”, so it will start at home dir.
Thank you, David! That’s just what I was looking for!
This is kinda the correct code for ubuntu cause it take the version number too –
wsl.exe -d Ubuntu-18.04
just type wsl.exe –list
for all the list of distros and add accordingly.
Thanks for the article super helpful.
Thank for the tip. I never knew it.
I think being specific with the version number is helpful if you have installed multiple distributions.
No,
I have installed just Ubuntu 18.04 and it was failing for me.
It worked just after I have changed it to wsl.exe -d Ubuntu 18.04.
Thank you very much for the article, and thank you very much for the tip David!
Looks like the version number is important. Thanks for letting me know Felipe.
Can’t get it to run from the terminal dropdown. I have installed Ubuntu and it executes fine on its own.
棒!!!
I have followed the above instructions and it adds a link in the menu however when I click on it, It runs for a split of a second and closes down. I recorded the screen and ran it in slowmo to read the error “There is no distribution with the supplied name”
I have upgraded windows, installed terminal, installed ubuntu 18.04 -LTS and ubuntu is running on my windows machine.
I think it’s a problem with the distribution name you supplied in the JSON file. Double-check the name. If you are using a specific version, you need to add that version number too. Use
wsl.exe –list
command to check the list of installed distributions.wsl.exe -l returns
~$ wsl.exe -l
Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)
I have checked the name and it reflects the instructions. here is what Is in my file
“commandline”:”wsl.exe -d Ubuntu 18.04″,
Solved,
I needed a hyphen between Ubuntu and the version number -> ”wsl.exe -d Ubuntu-18.04″
Hi, thanks for letting me know. I’ve corrected the mistake and updated the post to reflect the changes.
Want Ubuntu as your default? In the config file, use the GUID of Ubuntu and set it in the defaultProfile key near the top of the config file.
That is an awesome tip. Thanks for sharing.
I installed Ubuntu on my Windows 10 system today and the install automatically added Ubuntu to the drop down menu in Windows Terminal. I was almost disappointed that I didn’t have to add it myself. 🙂
Event easier in updated Windows Terminal:
{
“guid”: “{d0b53d8e-9ee2-4dcb-b553-928eac08826c}”,
“hidden”: false,
“name”: “Ubuntu-20.04”,
“source”: “Windows.Terminal.Wsl”
},
That’s awesome. Thanks for sharing.
I confirm that this worked for me:
“commandline”:”wsl.exe ~ -d Ubuntu-20.04″
thanks a lot