Skip to main content
Dublin Library

The Publishing Project

EPRDCTN in the command line: WSL Interoperability

 

One important thing that Windows users should know. There is a reason why we went through all the work of installing PowerShell and WSL: Interoperability.

WSL and Powershell were designed to work together and are continuously improved on the interoperability front. This can take one the following ways:

You can run Linux commands from Windows prepending the wsl command to the command you want to run. The example below runs Ace installed via NPM on Linux.

If this meets your needs, then you don't need to install Node on Windows. Running wsl node will take care of it when working on PowerShell and node will work when running on WSL.

wsl ace --help

You can mix commands too. The example below shows how to run a Windows command (dir) and pipe it to a Linux command with wsl (wsl grep foo).

dir | wsl grep foo

You can also do it the other way around and use Windows applications from the Linux shell. For example if you wanted to use Java to run Epubcheck from within a Linux shell you could run:

java.exe -jar epubcheck.jar

The .exe suffix to the application is important. It is what tells WSL that it's a Windows application; it also means that you don't have to install applications in both places, installing them in Windows should be enough.

Note that these commands don not work with aliases. As far as I know I can't create an alias in WSL's Bash shell and run it using wsl + alias.

Edit on Github