As some background, ubuntu1804.exe
is simply a Windows "App execution alias" (just type that at the Start menu to see the corresponding Windows settings screen). It basically runs the Microsoft Store (formerly known as UWP) app. That app, as you've found, launches its own terminal, known by the (horrible) name "Ubuntu Terminal". I'm sure there's some underlying terminal version that they used, but I'm not exactly sure what it is.
As you've already discovered, Windows Terminal is a much nicer option.
As it has done for you, Windows Terminal will auto-detect WSL instances installed from the Store and dynamically create a profile for it. But it may not launch exactly the way you want (e.g. starting directory).
The other thing you need to know is that the wsl.exe
command is a better way to launch instances rather than ubuntu1804.exe
.
I think I hear two related questions:
- First, how to have Windows Terminal launch Ubuntu to the home directory instead of
%userprofile
- Second, how to launch that from the commandline (so that you can create a shortcut to pin on the taskbar, for instance).
You could fix your issue (at least) two ways. The first would be to modify your startup script. I personally don't recommend this -- The second option is better, IMHO. But if you want to, I'd modify .profile
(since you probably only want this to happen in a login shell). And just add your cd ~
at the bottom. I haven't tested this, but it should work assuming that ubuntu1804.exe
launches the default shell as a login shell. There's a chance that it doesn't.
The better option, though, is to modify the Windows Terminal profile for your Ubuntu 18.04 instance. I'm going to give some "extra" instructions here in case you (or someone who finds this answer in the future) has more than one WSL instance/distribution installed:
First, run wsl.exe -l -v
(in PowerShell, Ubuntu WSL, or CMD). Take note of the name of your instance. I'm going to assume this is Ubuntu18.04
for the commands below.
Then, in Windows Terminal, open Settings (Ctrl+, by default, or use the menu).
Look for your Ubuntu 18.04 profile. It should be something like this:
{
"guid": "{unique-to-you}",
"hidden": false,
"name": "Ubuntu 18.04",
"source": "Windows.Terminal.Wsl",
},
The source
is for the Dynamic Profile.
Since you're going to give it your own profile settings, comment that out. And add a commandline
option like so:
{
"guid": "{unique-to-you}",
"hidden": false,
"name": "Ubuntu18.04",
//"source": "Windows.Terminal.Wsl",
"commandline": "wsl.exe ~ -d Ubuntu18.04",
"cursorShape": "filledBox" // or put this in your
},
Remember, that wsl.exe ~ -d Ubuntu18.04
should use whatever your actual instance name is from the wsl -l -v
we did before.
The (undocumented, as far as I can tell) ~
, of course, tells it to start in your home directory. You could also use the wsl.exe --cd
argument, but it requires a Windows path, so it would have to be something like wsl.exe --cd "\\wsl$\Ubuntu18.04\home\username"
.
Now Windows Terminal should launch your instance into your home directory.
Since it sounds like you already have that profile set as your default, you can just pin Windows Terminal to the Taskbar and launch it now, and you should be good.
But if you had a different profile that you wanted to be the default, you can still launch Windows Terminal using wt.exe -p Ubuntu18.04
(or whatever the profile "name" is in your settings.json
).