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.