Pretending WSL commands are native to Powershell

Today I have solved one of the biggest frustrations in Windows - no availability of Linux commands. If you are on Windows, WSL is a life saver, but that only works from inside the WSL bash console (am I calling it right?) so you would have to open another console, map windows mount to the correct path, and that might or might not work. Pretty tedious.

Another solution is prepending every command with wsl i.e. to call grep from powershell, you would write wsl grep... etc. This is better but still sucks when you forget you are in windows.

image-20220902161348425

So today I found a perfect solution - there is a powershell module called WSL Interop that makes powershell pretend the commands are available on windows.

Quick Start

If you don’t want to read the whole manual, installation is actually pretty simple:

Install-Module WslInterop

That does it.

Then to make a command available in powershell:

Import-WslCommand grep

That does it:

image-20220902161625610

To persist those, just add a set of Import-WslCommand to your powershell profile!

The original really awesome article I stumbled upon is here.

Thanks! You can always email me or use contact form for more questions/comments etc.