How to use WSL as default terminal in WebStorm or any other JetBrains' products?

For me the version was fetched and set automatically, after I opened a project located in \\wsl$\Ubuntu-20.04\home\my-user.

Webstorm set the shell path to wsl.exe --distribution Ubuntu-20.04

I use Webstorm version 2020.3 EAP currently


After a bit of search on google found a solution to my question.

First figure out the default wsl with the command:

C:\Windows\System32\wslconfig /list

Windows Subsystem for Linux Distributions:
Ubuntu-18.04 
Legacy (Default)

then I set the default to Ubuntu-18.04 by

C:\Windows\System32\wslconfig /setdefault Ubuntu-18.04

Finally set the terminal path in Webstrom settings>tools>terminal to

C:\Windows\System32\wsl.exe

Now open the terminal it is correctly move the current directory to the /mnt/c/blah/blah


Set:
Settings > Tools > Terminal > Shell path

Equal to:

"C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\ubuntu.exe" run

change setting


The result is:

resulting terminal


Settings -> Tools -> Terminal change cmd.exe to C:\Windows\System32\bash.exe and restart Webstorm.