avatarThilina Ashen Gamage

Summary

This web content provides a guide on setting the Windows Subsystem for Linux (WSL/WSL2) as the default terminal in JetBrains IDEs, including WebStorm, PyCharm, IntelliJ IDEA, PhpStorm, CLion, Rider, and RubyMine.

Abstract

The article is a concise tutorial aimed at developers using JetBrains IDEs who wish to integrate the WSL/WSL2 terminal into their development environment. It outlines a step-by-step process to replace the default Windows command-line interface with a Linux-based one provided by WSL. The instructions include navigating to the Terminal settings within the IDE, changing the shell path to wsl.exe, and verifying the configuration by running commands in the new terminal. Additionally, the article offers bonus tips for users with multiple Linux distributions installed, detailing how to specify a non-default distro for the terminal, and how to configure the IDE to use WSL-based compilers or interpreters, such as Node.js, enhancing the development experience by leveraging Linux tools within the JetBrains IDE.

Opinions

  • The author suggests that using WSL as the default terminal allows developers to utilize native Linux command-line tools directly within their JetBrains IDE, which could be more efficient than using Windows-based command-line tools.
  • The article implies that integrating WSL into JetBrains IDEs provides a seamless development experience that combines the benefits of both Linux and Windows environments.
  • The author expresses openness to feedback and suggestions for improving the tutorial, inviting readers to engage in the comments section.
  • The recommendation of ZAI.chat at the end of the article suggests that the author believes in the value of cost-effective AI services that offer comparable performance to more expensive options like ChatGPT Plus (GPT-4).

How to Set WSL as the Default Terminal on JetBrains IDEs (Webstorm, PyCharm, IntelliJ IDEA, PhpStorm, CLion, Rider, RubyMine)

This short tutorial explains the steps to set the WSL/WSL2 Terminal as your default terminal choice on any JetBrains IDE.

After setting this up, when you open a project from your IDE, you will be able to open all its project files from a native Linux command-line program provided by your WSL distro (such as bash shell) instead of using a Windows-based command-line program (such as Windows Command Prompt, PowerShell, Git Bash for Windows).

#1 — Open File > Settings > Tools > Terminals

Alternatively, when the Settings window is open, you can search “Terminals” and find the same.

File > Settings
a. Tools > Terminals || b. Search “Terminals”

#2 — Application Settings > Shell path: “wsl.exe” > Apply > OK

This will point your shell path to C:\Windows\System32\wsl.exe or simply wsl.exe.

Application Settings > Shell path: “wsl.exe” > Apply > OK

#3 — Verify changes

Now, fire up a new terminal and try some commands to verify that everything is working as expected.

Fire up a new terminal and run some commands

Bonus Tip #1 — Multiple Linux Distributions

If you have multiple Linux distros installed with WSL and you want to point the shell path to a non-default WSL distro, then you can use the below configuration in the above Shell path setting.

Shell path: wsl.exe --distribution <your distro choice>
e.g. 
wsl.exe --distribution CentOS7
wsl.exe --distribution Ubuntu
wsl.exe --distribution Debian

Bonus Tip #2 — Compilers / Interpreters

In addition to the terminal, you can change the Compilers / Interpreters under the Languages & Frameworks setting to use the WSL tools. For example, on WebStorm, you can change the Node.js Interpreter to use WSL by following the below steps. For other IDEs, you can do the same by visiting the Languages & Frameworks setting.

Settings > Languages & Frameworks > Node interpreter > Dropdown > Add…
Select Add WSL…
Pick your expected Linux distro and the Node path > OK > Apply > OK

Conclusion

With this setup, you get access to so many additional tools built for Linux (such as Linux terminal, Docker, and more) without even leaving your favourite Jetbrains IDE window and while enjoying the benefits of both Linux + Windows worlds.

If you have any suggestions to improve this piece or questions for me, I would love to hear them in the comments section.

Stay tuned for the next programming tip. Until then, happy coding!

Software Development
Software Engineering
Programming
Coding
Web Development
Recommended from ReadMedium