Reputation: 71
Is there a way to run Pycharm from wsl terminal by typing the command like charm <file_name>
or pycharm <file_name>
, just like it is with vscode where you type code <file_name>
?
Upvotes: 6
Views: 15760
Reputation: 473
Create an alias by adding this function in your .bashrc file or .zshrc file:
1.
ij(){
# update this path by the path where exist file idea64.exe of your IDE
# Jetbrains in your windows machine
/mnt/c/Users/put_your_username/AppData/Local/Programs/IntelliJ\ IDEA\ Ultimate/bin/idea64.exe $1
return 0
}
$ source ~/.bashrc
or
$ source ~/.zshrc
then you can start calling the alias ij (you can choose another name for this alias):
$ ij <path_of_your_code_source>
Upvotes: 0
Reputation: 553
From this article on How to run Windows 10 programs in a WSL Linux shell, you can already run Windows programs from WSL ex. notepad.exe
. This is because the program in the WSL path seems to be in sync with Window's path. You can add the path to the PyCharm executable to the path variable, C:\Users\trakw\AppData\Local\JetBrains\Toolbox\apps\PyCharm-P\ch-0\221.5921.27\bin
, restart WSL and run pycharm64.exe
which start PyCharm.
If you're using JetBrains Toolbox to install PyCharm, C:\Users\trakw\jetbrains\bin
, containing the batch file pycharm.cmd
to run PyCharm, is already in the path variable.
Running pycharm.cmd
in WSL will give errors because the .cmd file is written in batch which WSL doesn't recognize.
You need to run it using cmd.exe /c pycharm
.
You can add the modified code below to ~/.bashrc file in WSL, so you can run cmd pycharm .
.
# Usage : cmd pycharm .
cmd() {
CMD=$1
OPEN=$2
WIN_PWD=`wslpath -w "$(pwd)"`
WIN_OPEN=`wslpath -w ${OPEN}`
pushd /mnt/c;
cmd.exe /c "${CMD} ${WIN_OPEN}"
popd;
}
# Disable pushd echoing
pushd () {
command pushd "$@" > /dev/null
}
# Disable popd echoing
popd () {
command popd "$@" > /dev/null
}
There is still problem. This cmd pycharm .
in WSL works with projects in \\wsl$
created in PyCharm. For non-project folder in \\wsl$
, the error below will show up. However, pycharm .
in cmd, works with any directory.
Upvotes: 3
Reputation: 29
Yes. It's possible, if you using Windows 11: https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
Upvotes: 1