How to run the Babun shell in Cmder

I want to show you how you can the Babun shell in Cmder.

From my previous blog posts you know I am a fan of Cmder on Windows. It gives me a powerful shell as a replacement of the normal cmd.exe, and it also lets me run Bash and Zsh in the Windows Subsystem for Linux (WSL).

That said, Cmder does not provide a full featured *nix shell, but an extended Windows cmd prompt. And while Bash (or Zsh) on the WSL provide with an full featured Linux shell, it has some drawbacks as it really IS a Linux environment. For example, when you install certain Node packages in your project like PhantomJS, they will bring the Linux version and executables, and you can’t run them from your normal Windows environment.

Babun is a tool, that can bridge this gap.

What is Babun?

Babun is a package of different other tools. First it brings you Cygwin, which allows you to compile an run Linux programs in your Windows environment. It then brings a real Bash and also Oh-My-Zsh that runs natively on Windows (not on the WSL). And it comes bundled with a lot of different other Linux shell tools.

Install Babun

Installing Babun is extremely easy. Just go to http://babun.github.io/, download the Zip package, unpack it and run the install.bat file. This will install Babun and all dependencies into the folder ~\.babun in your user profile.

That also makes uninstalling Babun very simple: Just make sure that no Babun windows are open. Then delete the .babun folder from your user profile and it is completely gone.

Configure Babun (& install Powerline fonts)

I already mentioned that Babun comes with Oh-My-Zsh, and a lot of you can configure use Powerline fonts. Powerline fonts are fonts that have some additional glyphs in them to display arrows or branch symbols for more information about the environment. This step is optional, but you’ll miss out a lot of themes when you don’t install the Powerline fonts, like this one:

Powerline in action
Powerline in action

To install the Powerline fonts go to https://github.com/powerline/fonts, clone the repository and run the install.ps1 powershell script. Then open the Windows fonts settings, search for fonts that have Powerline in their name and select one.

Then open Babun, and enter nano ~/.minttyrc (or use vi, if you know how to exit it again), and enter the following line:
Font={font name of your choice, as displayed in the windows setting}. I chose Space Mono, so my line reads Font=Space Mono for Powerline.

Then edit your ~./zshrc and configure a theme you like. A lot people like to use agnoster. For a selection of themes have a look at https://github.com/robbyrussell/oh-my-zsh/wiki/themes.

Run the Babun Shell in Cmder

Now, that you have installed and configured Babun and zsh, it is time to unleash the full power and pack it in Cmder.

Open up Cmder and press Win + Alt + T to open the Startup -> Tasks configuration window like so:

Configure Babun in Cmder
Configure Babun in Cmder
  1. Click on the + sign to add a new Task
  2. Set a name for your Task (i.e. Babun)
  3. Set the Task parameters
    Make sure to configure the default directory to where you want it
  4. Set the Task command

The task parameters for me are:
/icon "%userprofile%\.babun\cygwin\bin\mintty.exe" /dir "D:\Dev"
The task command is:
%userprofile%\.babun\cygwin\bin\mintty.exe /bin/env CHERE_INVOKING=1 /bin/zsh.exe

Roundup

We learned that Babun is a Cygwin-based shell that enabled you to run Zsh (or also Bash) directly on Windows, without using the Windows Subsystem for Linux.
After installing Babun, we configured it and also made use of the fancy Powerline fonts that offer us much more information about our current folder like the Git branch.
Finally we configured a Cmder task to open Babun (or, in fact, the contained mintty directly) with Zsh in our console emulator.

I like encourage you to try out different powerline fonts (change them in ~/.minttyrc) and also different oh-my-zsh themes (change them in ~/.zshrc), and if you end up with a theme you really like, further customize your environment to your individual needs. A customized environment is just so much more empowering and makes you more efficient and happy with your work.