Developing for OpenFOAM on Windows 10 – Part 4

Customizing colors in the WSL terminal

The default colors in the Ubuntu WSL terminal are not very readable. In particular, the blue color does not read well on the black background. While it is possible to customize colors in bash, a simpler workaround is to change colors using the Windows settings. To do this, click on the Ubuntu logo in the top-left corner of the WSL terminal window, and select Properties.

This will open a dialog box with the specific settings to customize the launcher of the Ubuntu WSL terminal:

Choose the “Colors” tab, and set:

  • Screen text: Black
  • Screen background: White
  • Popup background: leave unchanged (purple)
  • Popup background: White

This will make the terminal more readable, at least according to my preferences.

Editing code from Windows and compile it in WSL

Editing files in WSL from both Windows and Linux is possible if the files are stored on the Windows file system. However, some care must be taken to avoid troubles. Before proceeding, please read this blog post, which clarifies the important points. More technical details are available here.

The easy way to edit code in Windows, and use it in WSL is to store the code in a directory on Windows. Any directory in Windows drives (C:\ etc) is fine. These drives are automatically mounted in WSL, and accessible at the path /mnt/<drive_letter>/. For example, the C:\ drive is accessible to the Linux system running in WSL at the path /mnt/c/

One simple approach is to create a folder in C:\, which, in my case, I called SharedWSL, as shown below.

The directory is accessible in the WSL terminal at /mnt/c/SharedWSL and it is writable by both operating systems.

It is convenient to create a shortcut on the Windows desktop to easily access this directory from the Windows environment. To achieve this, right click on the SharedWSL folder, and select “Create shortcut”.

Windows will inform you that it cannot create one in C:\, and offer the option to create it on your desktop. Accept to complete the operation.

Setting up your Windows text editor to save files properly in the WSL operating system

It is recommended to use a text editor which can save files with UNIX end of line. Most of the text editors let the user select this option. Here settings for Notepad++ are shown.

Notepad++ offers two ways to select the UNIX (LF) option:

  1. Global setting in the Settings -> Preferences… menu, under the “New document” tab:
  2. On a per-file basis, at the bottom of the notification area of the editor, boxed in red in the figure

Enjoy  :mrgreen:

This offering is not approved or endorsed by OpenCFD Limited, the producer of the OpenFOAM software and owner of the OPENFOAM® and OpenCFD® trade marks. Alberto Passalacqua is not associated to OpenCFD Ltd.


  • Alberto

    Thanks! I think the default font is OK. The problem was mostly the blue color, which is not readable on a black background. There are more refined strategies to fix it, like editing the ~/.bashrc file. My workaround is a quick fix, if the user is OK with a white background.

    • Alberto

      If you use OpenFOAM on Ubuntu WSL, and install the packages from the OpenFOAM Foundation, you already have paraview installed.
      To make it work, you need to install an X server on Windows, such as Xming. Once installed, type the following commands in your WSL prompt:

      echo “export DISPLAY=:0” >> .bashrc
      source $HOME/.bashrc

      Then, to use paraview or paraFoam, simply run Xming in Windows before launching the paraview (or paraFoam) command in the WSL terminal.

      Note: If you store results on the shared disk space, you can avoid this, and directly use paraview on Windows.

      I hope it helps!