Hipsterising Windows: cygwin vs babun vs git bash vs powershell – the Onion scale

It is clear with Azure that Microsoft is adopting a tool chaining strategy based on Git and other useful terminal tools. Gone are the days of drawing pretty boxes in a CASE tool and expect the stuff you cooked up in thin air to be high performance, scalable and easily provisioned through cloud providers. The first step is get yourself tools that can actually help your everyday devops life. Hark! let us hipsterise Windows and bring on the terminals!

So if you take pride in your .dotfiles, git-foo and devops craftsmanship, but got stuck navigating the treacherous GUI waters of Redmond county, then this is for you. This blog post aims to be an opinionated and cynical evaluation of 4 major terminal options available in Windows for running Git and other common everyday *NIX tools. The scale are in unit of Onions, because you will be weeping when you start working on these abominations. Command Prompt did not make the list. It died with DOS 6.22.

tl;dr

Use Mac or Linux. Save yourself while you can. If you absolutely cannot avoid using Windows as the main platform, or unable to run it through Virtualbox, then install Babun; though the experience is no where near the level of “epic unicorns riding waves of candy rainbow”, it is still very solid. Be prepared to deal with stuff like BLODA (Big List of Dodgy Apps), you’ll question the existence of antivirus as a marketing and vendor lock-in strategy, and really get some hands-on practicing copious amounts of “let me reboot my laptop to see if it fixes the problems. Oh it did.” Start rubbing your ears and say “Wooooosa”, and remember the fault is not with Babun, but with Windows.

Powershell

Git can be installed via chocolatey. This is a package manager that can be installed in Powershell with this monstrosity of a command.

PS:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

Chocolately is billed as apt-get for windows, but you would need Powershell know how, and you best be a C# developer. Guessing if you do devops on *nux/*BSD platform, this is not for you. Naturally, you will bloat your xbox PC since none of the UNIX tools exists. Forget about curl because in the world of Powershell, curl equivalent looks like…

PS F:\> (New-Object System.Net.WebClient).DownloadString("http://google.com")

Pros:
Ships with Windows and has a fancy blue background. Quite possibly awesome with stuff like Sharepoint. Network proxy works without additional configuration. But why Sharepoint… why…

Cons:
You need to know your C#. Pipelining involves objects, not strings. My guess is that sed and awk would not work without a heap of ToString() method calls. Conceptually very powerful for having a debug console for everything Microsoft. This is extreme vendor lock-in.

Verdict
4/5 Onions. Balling my eyes out reading MSDN documentation to just trying to add headers to the Webclient. In contrast, this would be the perfect platform if you do know your C#. I do not see very sharp, if you would pardon the pun.

Cygwin

This is old school. Both Git and package managers are available. Options here are apt-cyg and pact. Cygwin is POSIX compliant and can be the portable platform for most things *NIX.

Pros:
Copy and pasting is made slightly easier with using the default clipboard. No need to fiddle with pbcopy or “*y and “*p. Yes, can’t think of any other pros besides the fact that most tools are available here.

Cons:
Ready to start using dos2unix and unix2dos all over the shop. Cygwin looks dated but a little .dotfiles TLC will spruce it up real nice. But be prepared to download the internet for the tools you want. You will probably come across a bunch of quirks and work around to get stuff going. Note that node.js no longer supports Cygwin either. Need to explicitly setup HTTP_PROXY env variable for network proxies.

Verdict
3/5 Onions. It feels like I am back in university trying learn things instead of producing results.

Babun

Best in class here. It is essential Cygwin minus the quirks and ugliness. Has plenty out-of-the-box tools and a nice package manager named pact that seems to work alright. pact is a bit like brew for Mac.

Pros:
Purrrty and super fast to get going. zsh is my new fav shell.

Cons:
Copy pasting is a bit of a pain. Babun is installed in its own directory, sort of like a mini chroot environment. This makes accessing your windows stuff feels a little jail-breaky. But why would you want to do that anyways when you got a perfectly good shell? Need to explicitly setup HTTP_PROXY env variable for network proxies.

Verdict
1/5 Onions. It is not all that bad and has most things you need for a flying start. It is however not an integrated terminal environment like the ones in Mac and Ubuntu. There are quirks. For example, getting gvim to pop up in windows, (instead of using pact install gvim, which uses xterm and lord knows what would happen), the following script was added to make it work, provided that gvim.bat lives happily in the %SystemRoot% folder.

#!/bin/sh
cmd /c gvim.bat "$@"

git bash

Not POSIX and not a derivative of Cygwin. This is MSYS, which is a collection of GNU utilities based on MinGW. Being non POSIX, it uses Windows C native runtime directly. It is as bare mental as Windows can go, if you would ignore the antivirus and el crapo boot time.

Pros:
Great for git. That is about it. It also doesn’t care if files not UNIX format delimited. Pretty chillax this tool.

Cons:
Ugly as hell. Need your TLC from .dotfiles to make it visually appealing. Need to explicitly setup HTTP_PROXY env variable for network proxies. If you want other tools then you are shit out of luck. No package manager as far as I know. I

Verdict
2/5 Onions. Its not all that bad again, but it is really not ideal. Copy and pasting is a pain with this marking business.

Conclusion

I use my mac for real work. I am too afraid to install Node, Ruby, Perl or Python stuff on these xbox laptops. Virtualbox and Vagrant is a must have for sanity.

Advertisements

13 thoughts on “Hipsterising Windows: cygwin vs babun vs git bash vs powershell – the Onion scale

  1. Yes, you’re absolutely right! After several months trying to get code produced in Cygwin running in a Windoze box, and miserably failed, I’m switching to a Linux VM for developing and another Windoze VM for building/deploying/testing. Maybe someday the elder Rubysts will discover some black magic that help to move building and deploying for Windows to the Linux VM. Or maybe they’ll conclude Smalltalk was right…

  2. I think the evaluation of PowerShell is not completely fair. The example you have about curl – PowerShell has Invoke-WebRequest (or iwr) – so iwr http://google.com is all you need to do to get the object. Hence (iwr http://google.com).Content will give you the html contents.

    Also, you do not need any knowledge about C# to use Chocolatey. I have zero knowledge about C# (may be you need it to maintain packages, I have no idea) but as far as using it (installing/updating/uninstalling), it is pretty similar to zypper that I’m used to from openSUSE.

    Last, pipelining objects instead of text is actually a pro IMO – for example, if you want a property, you just ask for it – you don’t have to parse, guess, etc. I guess this depends on what kind of tool one is familiar with.

    Once you get used to it, PowerShell is actually pretty nice, especially with some modules – PSReadline makes it almost zsh-like, and posh-git is pretty nice too. (I do miss zsh with oh-my-zsh a bit sometimes though ..)

    • ^ beat me to it (by several months) re: iwr, which if anything is shorter than curl.

      On C#, not only do you not need any C# knowledge to use Powershell but it really doesn’t help you at all. I think you’re confusing C# and the .Net Framework. You don’t NEED to know about it but yes, it is full first-class access to the .Net Framework which puts the power in Powershell (pardon the pun). Saying that needing to understand the .Net Framework tools to be efficient in Powershell is a negative makes about as much sense as saying needing to understand Unix commands to use bash effectively is a negative. Yes – to be effective with a tool, you need to understand the tool.

      They’re different tools for different jobs. I’ve very quickly taken to Babun for general use but still prefer Powershell for non-trivial tasks. Overall I give them each 1 onion as long as you’re not on Windows 8 or newer, in which case nothing can save you from the 5 onion onslaught.

  3. “My guess is that sed and awk would not work without a heap of ToString() method calls.” – sed and awk should be available if you have git installed – if not, get them by running “cinst GnuWin”. You will not need any ToString method calls to use them in the pipeline, since Powershell automatically converts when passing to a binary utility.

    The bash utilities are still the best for working with text (from within Powershell, of course), but for everything else, I highly recommend Powershell’s own commands. What you can do with an object pipeline is so powerful once you get used to working with it, that you may find yourself wishing for Powershell when you work on non-Windows machines.

  4. Unless you’re developing native GUI applications, Vagrant pretty much completely solves the Development Problem on Windows. babun is there for those times when you want a pretty terminal for something simple and don’t want to spin up a VM.

    The thing is, I’d go so far as to almost recommend Vagrant-style workflows even on Mac OS X. After destroying my Haskell installation several times through cabal hell, I’ve learned the value of sandboxing in general. And OS X is insidiously Unix-like-but-not-really-quite-there, so 90% of the time things work fine and then 10% of the time you’re in the “well, let’s just restart the computer…” or “well, let’s just completely uninstall every package and start over…” territory.

  5. I spent a lot of time in babun and on various flavors of linux (centos mainly) and if you spent enough time on babun; you can customize it say, 90% close to what you’d expect on linux box. Not perfect but much better than cygwin.

  6. I’m personally a huge fan of Msys2. I really love that they have the pacman package manager for getting the various Windows/Linux/Mingw/Cygwin utilities easily installed and playing around with things with handy utilities like wintty that uses the Windows process interoperability instead of pipes, as those can fail hard when using Windows tools in an *nix environment.

    I’m really hoping Babun moves to using Msys2 with Mintty and allows mixing their ‘pact’ package manager with pacman.

  7. Hi
    Great article !!!!!
    I recently come across Cmder ( http://cmder.net/ ).
    A Console Emulator based on Conemu and enhancements from Clink.
    In its full installation it uses git-for-windows with all the git and unix like stuff in its setupFile.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s