Problem :
I have installed WSL2 with Windows 10 and downloaded and set up Ubuntu successfully.
I have installed and set up ConEmu terminal to run Ubuntu successfully.
But ConEmu opens Ubuntu in C:UsersMyUsers
I want to start up in Linux (Ubuntu) HomeMyUsersMyProjectFolder Directory
I tried to used each of these commands in ConEmu – Settings – Tasks – 6- Bash (or 7- Ubuntu) but none of them worked:
%windir%system32wsl.exe -cur_console:pm:/mnt --distribution Ubuntu -c "cd"
%windir%system32wsl.exe -cur_console:p -c "cd"
%windir%system32wsl.exe -cur_console:p -c "cd /home"
%windir%system32wsl.exe -cur_console:pm:/mnt --distribution Ubuntu -c "~"
set "PATH=%ConEmuBaseDirShort%wsl;%PATH%" & %ConEmuBaseDirShort%conemu-cyg-64.exe --wsl -cur_console:pm:/mnt -C "~"
wsl.exe -cur_console:pm:/mnt -C "~"
Solution :
Short Answer
Set up a ConEmu task with either:
%windir%system32wsl.exe -cur_console:pm:/mnt --cd \wsl$UbuntuhomeMyUserMyProjectFolder
-new_console:d:\wsl$UbuntuhomeMyUserMyProjectFolder %windir%system32wsl.exe -cur_console:pm:/mnt
Details
For completeness, I’m going to repeat the information from the previous answer that was deleted for starters. Even if it doesn’t directly answer your (updated) question, it is still good to have here as a reference.
There are multiple techniques for specifying the starting directory for a WSL instance:
- You can launch directly to the WSL user’s home directory using the (at this time, still undocumented)
wsl ~
shortcut. - You can launch to a specified directory using the (also undocumented)
wsl --cd <WindowsDirectory>
commandline. Note that this takes a Windows-style path to the directory, as opposed to a Linux path. For instance,wsl --cd C:
. To use a path inside the WSL instance, you can use the Windows’\wsl$<distroname>path
. So your/home/myuser/myproject
would becomewsl --cd \wsl$Ubuntuhomemyusermyproject
(assuming that your distribution/instance name is “Ubuntu”). - You can set the directory in the parent process before starting the WSL instance. WSL will launch into the current directory by default. For instance, from PowerShell:
PS> Set-Location C: # a.k.a. "cd C:"