We are using WSL 2 and Ubuntu throughout this article, but you can apply these tips to any distro.
1. Installing Zsh
Zsh, also known as Z-shell, is a more powerful and customizable shell than Bash shell, the default shell for most Linux distros. Zsh comes with advanced features like autocompletion, autocorrection, built-in Git integration, and support for installing themes and plugins. To install Zsh, run: With Zsh installed, you can install frameworks like Oh My Zsh to manage Zsh.
Installing Oh My Zsh
Oh My Zsh is an open-source, community-driven framework that lets you manage themes and plugins for Zsh in a more convenient way. You can install Oh My Zsh using curl and git, which come preinstalled with most of the WSL distros. If you don’t have them installed, you can always install them using sudo apt install curl git. Now that we have cURL and Git installed, run: This will clone the repository and install Oh My Zsh. In the installation process you will be prompted with the question “Do you want to change your default shell to zsh?” Press Y and Enter to make it your default shell.
Installing Powerline Fonts for Zsh
You might have noticed some weird symbols showing on the terminal. This is because we don’t have the appropriate fonts (Powerline) installed. This will clone the fonts in your Windows home directory of Windows.
Customizing Zsh
Oh My Zsh comes with so many preinstalled themes, and we can use them by configuring our “~/.zshrc” file. You can find the names of all the preinstalled themes of Oh My Zsh here.
2. Configuring WSL to Limit Its CPU and Memory Usage
WSL can be quite resource hungry and a memory hog, especially when you are using applications like Docker, which can take up a lot of your usable memory. The problem is, sometimes it doesn’t unallocate your memory, even if it doesn’t need that extra memory anymore. This can result in your entire PC slowing down and even lagging. You can easily fix this issue by limiting how much memory and how many CPU cores WSL can access. This will set the maximum memory usage limit to 3GB, and WSL will have access to two virtual processors. For example, if your CPU has four threads, WSL can now access two of those. You can also configure your WSL for things like limiting the swap usage, turning on console debugging, and using a custom kernel. You can check out Microsoft’s official docs for all the configurable options.
3. Using Windows Git Credential Manager on WSL
If you have used Git in WSL, you might have already noticed that WSL keeps asking for your Git credentials every time you push something on GitHub. To fix this, you can use your Windows Git credential manager for WSL and have the same credentials across Windows and WSL. To set your WSL’s Git to use Windows Git credential manager, run the following command in your WSL terminal:
4. Using a VNC Server to Use GUI Apps on WSL
Although WSLg can run GUI apps, it’s only limited to Windows 11 and Windows 10 insider versions. Also, running a desktop environment is a mess in WSLg. A VNC server can come in handy if you want to access your Linux distros remotely. This will prompt you with two options for your display manager. We’re using lightdm here, but you can choose either one. Select “Ok” after choosing your preferred display manager.
Installing a VNC Viewer
With a VNC server installed and running, we can use a VNC server to access it. From the output, copy the port number under the “Local Address” column. Here, it is showing 0.0.0.0.0:5912 under the first “Local Address” column. The port number starts after : and is 5912. If you face issues like VNC Viewer taking too long to connect, you can retry with a different port from the “Local Address” column. You can use the WSL’s Linux distro in a GUI environment and install any GUI app in your Linux distro and use it through the VNC viewer.
Using a Script to Start the VNC Server
The VNC server creates a new display session every time you run vncserver. We can create a script to avoid that. and add these lines: and save the file. This will kill the first display session and remove the files associated with the session. From now on you can run “~/startvnc.sh” to start your VNC server at the first display session.
5. Transferring Files from Windows to WSL Easily Using File Explorer
Although you can transfer files from Windows to WSL, having a GUI environment for copying and moving your files comes in handy. You can use the built-in File Explorer of Windows for transferring your files using a graphical interface. This will open your WSL distros’ directories.