terminal: Opening Windows Terminal in current directory from right-click folder context menu (the `ubuntu.exe` bug)
Description of the new feature/enhancement
I couldn’t find a way to open up wt.exe
in a linux profile (e.g. Ubuntu
) via right-click in the context menu that pops up in explorer by setting the current working directory to whatever I was browsing before.
To rephrase: I added some HKCR\Directory\Background\shell\wt\command
key with wt.exe -d "%V"
so that I can Shift+RightClick in a folder in explorer.exe and have a Open in Windows Terminal with Linux
item in the context menu. Windows Terminal opens but the starting directory, no matter what I set the profile startingDirectory
field in the JSON to, is always set to my home directory. It would be nice if wt.exe -d "C:\\"
or whatever actually opened, for the linux profile, in /mnt/c
as starting directory.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 28 (7 by maintainers)
Is your profile using
wsl.exe -d Ubuntu
orUbuntu.exe
?The latter will not respect the starting directory, and always opens in $HOME
I had the same problem with Ubuntu-22.04 installed via Microsoft Store. The terminal always started in /home/<wsl-user>, no matter the current directory where context menu was invoked (on right click). Adding
"commandline": "wsl.exe -d Ubuntu-22.04 /bin/bash"
to terminal profile fixed the issue.WORKS!!!
Check if you really have sat up right distro name:
Try to run from CMD or PS:
Then open terminal settings (json file). Search for your profile and change “commandline” value to this:
or
Thanks for this! Managed to get it working by adding the
commandLine
to it. However, now when opening it normally, it will always open default to/mnt/c/WINDOWS/System32
. Is there a way to keep opening in current directory context menu, while also having it open in the default/home
directory when opening terminal on it’s own?I found a workaround to make this work: this opens up the shit+right-click context menu directory in Windows Terminal in the default profile (which I have set to Canonical’s own profile).
Ah, even WSL 1 doesn’t automatically map network shares.
WSL does not automatically map network shares. It cannot be launched in any directory that is not represented or representable in the Linux filesystem. You would need to mount them explicitly in
/etc/fstab
, and even then it may not be able to figure it out.This would make an excellent feature request for the WSL repo 😄
Thank you! Why didn’t I think of this?
Did you ever figure out why we have two? Which one should we use?
Workaround - add the following in
.bashrc
inside WSL:Came here to report that using
ubuntu.exe
DOES work with therun
command proceeding, which starts the default shell in the current directory (where invoked). So, for my Windows Terminal profile, I have the following in the Command Line setting:I would like to see the default change to use this setting value.
Source
You can pick icon from the internet, by setting Icon value to:
Or download and save it on your computer, then just set correct path to the icon.
For example I use one of local app icons (Linux icon):
That’s exactly it. There’s definitely and issue with the Ubuntu profiles that Canonical is shipping. Sorry about that! I’m reaching out to them to see what we can do here.
Interesting - canonical is shipping their own profile, but not one layered with the existing profile. Curious…