6 Ways to Improve Your WSL Experience

Wsl Neofetch

Microsoft’s Windows Subsystem for Linux (WSL) is a game-changer, providing a complete Linux experience inside of Windows. However, to get the best out of WSL, you can’t just rely on its out-of-the-box experience. This tutorial goes over a bunch of things that can make your WSL experience even better. We’ll be using WSL 2 and Ubuntu, the default for Windows 11, but you can apply these tips to any distro you choose to run.

Note: you can install Linux on Windows with WSL.

1. Installing Zsh

Zsh, also known as Z-shell, is a more powerful and customizable shell than Bash, 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:

Demonstrating Zsh installation within WSL

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 conveniently manage various themes and plugins for Zsh.

You need curl and git to install Oh My Zsh. Both usually come preinstalled with most WSL distros, but you can make sure they are installed by using:

sudo apt install curl git

Once you have both applications installed, run the following:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

This will clone the repository and install Oh My Zsh. During this process, it will ask you a question “Do you want to change your default shell to zsh?” Press Enter to make it your default shell.

Part of the Oh My Zsh installation within WSL

Configuring Zsh now is as easy as using your preferred editor to change the .zshrc file in your home folder to your liking:

To change the theme, choose one from this list and change the value of ZSH_THEME to it.

Setting Zsh theme under Oh My Zsh with the Nano editor

Here are some good themes that provide maximum legibility with a clean prompt that would suit someone new to Linux shells:

When you’re done with that, edit the line that starts with plugins to include all the plugins you’d like from this list.

Here are some plugins that may help navigate inside of WSL (and generally most Linux environments) easily:

  • git (already configured usually) – for easy aliases that make working with Git repositories easier
  • sudo – in case you forget to prepend your command with sudo, this automatically does it when you press the Esc key twice

Outside of these two plugins, everything else is very niche-dependent and tailor-made for specific use cases. For example, the python plugin will not interest someone who purely codes in NodeJS.

Forgot your password? Here how to reset a WSL user password

Installing Powerline Fonts for Zsh

Powerline is a plugin that helps display a large collection of extra symbols with zsh, bash, tmux, fish, and other applications.

To install Powerline, grab the master ZIP file from Powerline’s Git repository and extract the archive to a folder of your choosing. Open an instance of Windows PowerShell in administrator mode, then type:

Set-ExecutionPolicy Bypass

Navigate to the fonts-master folder that resides within another folder of the same name and then type:

Setting PowerShell execution policy to install Powerline fonts

2. Configuring WSL to Limit Its CPU and Memory Usage

WSL runs a full virtual machine within your Windows installation. Because of this, it will often use more memory than many other terminal applications, especially when you use memory-heavy apps within Linux.

The problem is that, like every other virtualization platform, WSL isn’t keen to let go of memory once it’s no longer needed. This may result in some sluggish performance overall. You can fix this issue by limiting how much memory and how many CPU cores WSL can access.

Create a new file in your Windows home folder called .wslconfig from within WSL:

editor "$(wslpath "C:\Users\[Your Username]\.wslconfig")"

Don’t forget to replace [Your Username] with your Windows username.

Write these lines into the editor (by default, Nano) and save it (Ctrl + X):

[wsl2]
memory=2GB
processors=2
Nano editor open with memory/CPU limitations configured for WSL

Feel free to play around with these limits as they suit you. This particular configuration will limit WSL’s memory usage to 2 GB and ensure that it uses no more than 2 CPU cores at a time.

Your changes will apply once you shut down WSL from your PowerShell with:

Open your default WSL again and run htop or top to verify whether your limitations are now in place.

Htop runningg within WSL showing limitations on memory and CPU

Remember, whatever you configure in WSL will apply to all of the distros you’ve installed for it.

3. Use Windows Git Credential Manager on WSL

If you’ve used Git in WSL, you might have already noticed that WSL asks for your Git credentials every time you push something into a repository. 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:

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe"

4. Transferring Files From Windows to WSL Easily Using File Explorer

Although you can easily access your Windows files in WSL through the /mnt/c/ directory tree, doing the reverse can be convoluted. However, we can use Windows’ own File Explorer to easily gain access to our WSL files using these simple steps:

Open File Explorer, and in the address bar type \\wsl$ then press Enter.

File explorer showing WSL root folders

Navigate through the folder tree until you reach your home folder, which will just be your username under home.

File explorer showing home folder for the default WSL distribution

Right-click the folder with your username and click Pin to Quick access. You now have a convenient way to navigate to your WSL home folder on your left panel.

Quick access menu in Windows File Explorer showing a WSL home folder

5. Easy Access to Windows Files from WSL

If you want easy access to Windows user directories in WSL, you can take advantage of Linux’s symbolic links.

Make sure you’re in your home directory.

Create a directory. Let’s call it “winhome.”

Create a symbolic link to your Windows user folder that leads to this new directory.

ln -s /mnt/c/Users/[Your Username]/ ~/winhome

Remember to replace [Your Username] with your Windows username. Listing the winhome directory should show a successful symbolic link now.

Listing the windows home directory from within WSL after creating a symbolic link

If we run a file manager within WSL, we can see the directory tree of our Windows home directory from within the Linux environment.

Windows folders seen from within a file explorer running inside of WSL

6. Install WSL Plugin for VSCode

If you ever wanted to run your own code within the WSL environment within Windows, VSCode has an extension that allows you to do just that. All of the runtimes you install in WSL, the Linux kernel, and every utility you’ve installed will be available to your development environment without any hassle.

All you have to do is go to the Extensions Marketplace within VSCode by clicking on the Extensions icon on the left-hand side of the application and search for wsl.

The official Microsoft extension will be the first result that pops up. Just click Install and you’re done!

The landing page for the official Microsoft VSCode WSL extension.

Once you’ve installed the plugin, return to your WSL terminal and navigate to a folder you’d like to use VSCode in then type:

Wsl Coderuntime

Some magic happens in the background and you’ll soon see VSCode running in Windows with your Linux environment. You’ll also be asked if you trust the author of the files within the folder you just opened VSCode in. Answer positively only if you know that the files contained within are trustworthy.

Wsl Trust

Where the Rubber Meets the Road

Linux has long become a programmer’s dream environment due to the innumerable libraries and frameworks that make just about anything possible. By running WSL, you get to enjoy all of this without missing out on Windows’ satisfying and “just works” graphical environment.

Frequently Asked Questions

Can I use an IDE on WSL using a VNC server?

Yes, you can use IDE in your Linux distribution using WSL. Although the performance is not the same as native apps, it’s quite usable.

Am I limited to the preinstalled themes of Oh My Zsh?

No. Besides the preinstalled themes, you can also install third-party themes for Zsh.

Do I have to configure WSL for each of my Linux distros?

No. Any configuration changes to WSL will be applied to all of your installed Linux distros.

All screenshots by Miguel Leiva-Gomez.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Miguel Leiva-Gomez

Miguel has been a business growth and technology expert for more than a decade and has written software for even longer. From his little castle in Romania, he presents cold and analytical perspectives to things that affect the tech world.

Leave a Reply

Your email address will not be published. Required fields are marked *