Setting up a reasonable and light-weight Linux-like (non-WSL) terminal environment on Windows

e · l · n
Nov 29, 2018

In my new job as a consultant and developer in Machine Learning and AI at Savantic AB, although we internally have a "choose your favorite OS" policy, we're from time to time running into situations where we need to do development on or for Windows. Being a heavy user of the Bash terminal on user on Xubuntu Linux myself, this quickly had me frustrated with how to do things quickly and efficiently on the commandline. The default terminal on windows (aka cmd.exe) is not the nicest thing to have to deal with, and the much more powerful PowerShell is different enough from bash that it will cause some frustration and grief.

So, what I was looking for was a no-fuss, lightweight, robust and as simple as possible solution to running my normal Bash-based workflow, but inside the main Windows filesystem, interacting with the Windows world. Turns out there are some solutions (hint: look at the thumbnail picture to the right). Read on for more info on that.

Windows Subsystem for Linux too heavy

First, I must mention the impressive work by Microsoft on the Windows Subsystem for Linux (aka. WSL), which more or less lets you run a full-blown (at least GUI-less, and not even completely GUI-less) distribution of popular Linux distros like Ubuntu and Fedora. WSL is awesome, but also kind of heavy to install, easily taking something closer to an hour to install (or that was my impression). It also has some odd behaviours like opening files in Windows from WSL will give you troubles with line endings (as you might know Windows uses \n\r for line endings while Linux uses just \n). Finally, the default bash terminal for WSL did not even have zoomable text. All in all, this made it clear that this is not the light-weight simple solution I was looking for. WSL is awesome, but too heavy that I will be comfortable to quickly install it on "any Windows machine" I need to spend time working on.

Enter Git-Bash and MSYS2

Thus, I continued my search. I found Git-Bash, which is part of the Git package for Windows. It provides a simple bash environment with git pre-installed and configured, and works extremely well for simple tasks.

The main drawback I found with Git-Bash was that it does not contain or allow an easy route to install my favorite terminal multiplexer / window manager: tmux. One nice blog post mentioned the system that Git-Bash builds upon, and that it sports a package manager which can install a lot more software: MSYS2. Long story short: I tried MSYS2, and now I'm (figuratively) in love. With a few (fixable) caveats I now can run pretty much my full command-line bash+tmux+vim+git(+etc etc) workflow from Xubuntu, IN WINDOWS, right inside the Windows filesystem ... and things just work!

So, for my own and others' documentation, I below provide documentation of the procedure I have so far followed to enable a comfortable very Linux-like bash environment in Windows.

How to set up a nice environment based on MSYS2

End result

If you follow the above instructions roughly, you might end up with an environment like this:

So far, I'm super pleased with this setup.

Some caveats

I noticed the following caveats: