25. May 2021

Windows Terminal – How to add a custom shell to dropdown menu with JSON Fragment Extension

Windows Terminal allows you to use and manage shells for CMD, PowerShell or WSL2 in one window.

Windows Terminal also allows registering custom shells to the application. One option is to edit the profile manually via Settings.

It’s also possible to use the so-called JSON Fragment Extension which lets you drop a JSON file into a directory and Windows Terminal will load information from the file. The major advantage is that you can move the file between computers without worrying about damaging HJSON format of the original configuration file.

The instructions on the Microsoft site are not very clear on how to add the JSON and I had to use debugger to determine the proper location.

First of all create a directory for your application (e.g. IPython) with following PowerShell command:

mkdir "$env:LocalAppData\Microsoft\Windows Terminal\Fragments\IPython\"

Open a file with .json file extension and specify there following content (e.g. fragment.json with full path “$env:LocalAppData\Microsoft\Windows Terminal\Fragments\IPython\fragment.json”):

{"profiles":
  [
    {
      "name":"IPython",
      "startingDirectory":"C:/",
      "commandline":"ipython"
    }
   ]
}

Save the file, close Windows Terminal, open new Windows Terminal, and IPython will be visible in the list of available terminals.

Select the IPython and you’ll get a new tab with the interpreter.

22. April 2021

How to run Linux GUI application on Windows WSL2 with MobaXterm and Windows Terminal

MobaXterm is a great software that allows running applications from Linux on Windows in a nice integrated way without the need of installing extra XServer.

MobaXterm has also support for WSL2 which makes it easy to launch Linux GUI applications from Linux on Windows.

After installation of Linux distribution like Ubuntu or openSUSE on WSL2, you will find new sessions with the prefix WSL in MobaXterm. Simply click the session label and a new terminal will be automatically configured to talk to the local XServer.

Now you can start any GUI command, e.g. xeyes.

The same XServer from MobaXterm can be used also from other terminals and shells like Windows Terminal. It’s sufficient to export environment variable DISPLAY in the Linux WSL2 session:

export DISPLAY=127.0.0.1:0.0
xeyes

Note: xeyes are part of x11-apps, you can install them by command

sudo apt install x11-apps