Coping with the OSS command line on Windows

Long time (23 years?) Windows user here.

I’m not leaving Windows anytime soon, for a variety of reasons.

But I do have a Macbook Air. Parallels lets me run the best apps, whether they are Mac apps or Windows apps, on one desktop. For example I’m writing this blog post using Windows Live Writer, the absolutely best blog authoring tool out there. It’s a Windows app but runs flawlessly on the Mac via Parallels.  It runs in a Window, has an icon on the Dock, etc…

I’ve found that doing OSS based development (you know, things like Git, Node.js, Ruby/Padrino, et’c…) simply work best on my Mac.  On Windows these things are a massive pain in the ass. But the other advantages of Windows outweigh this pain for the most part (I’m not a full time developer by any stretch).

Even worse, on the Mac I can easily integrate the native Mac command line stuff into my Windows development tools. It’s really common for me to be running Visual Studio 2010 in one Window, iTerm in another (zsh + oh-my-zsh!), and the Mac version of Sublime Text 2 in another. I can use iTerm for all the git, brew, blah, blah, blah command line stuff I need and alt-tab to/from VS2010 as needed.  Parallels makes the file system visible to both sides.

As you can see below I’m able to alt-tab between VS2010 (Win), Sublime Text 2 (Mac), and iTerm (Mac). Other than the Windows style toolbar on VS, it all feels pretty coherent.

macdesktop

On Windows, I can’t do the reverse.  I struggle to get msysgit and cygwin to work seemlessly with Windows apps.

Why?

Because the Windows command line ain’t Unix based and the stand-ins (MINGW32/msysgit and cygwin) are hacks on Windows. They are attempts to force Unix code to call into the Windows API at the application level. Because of this there’s an impedance mismatch between the OSS tools and the underlying OS. Not all tools are supported, and there’s weird behaviors.

I have made it all work. I can now do most everything I do on the MBA on my Windows workstation. Most of the command lines are the same too. And having Sublime Text 2 as my editor is just killer.

But I want it to be better.

So I have an idea:

Use virtualization to get a great Unix like command line on Windows, instead of trying to do it at the API level. 

This would require that:

  • Someone build a basic Linux distro with no GUI. Pre-configure it to use zsh as the shell with oh-my-zsh setup.
  • Host this distro in one of the OSS or free virtual machine packages, such as Oracle’s VirtualBox,
  • Build a VM extensions that
    • Maps the Windows (host) file system into the guest.  So that within the Linux command line I can do “subl .” and the Windows version of Sublime Text 2 will load the contents of the current directory.
    • Supports copy/paste (this already works well in VirtualBox).
    • Allows the command line windows to feel like a Windows app (but with the features of iTerm for the Mac!).

Seems possible to me…

Listen, it’s well known I hate using Linux. But that’s Linux as a workstation. If this thing existed I’d never have to deal with any of the crappy GUI stuff going into Linux today. Just good old zsh.

Is this a crazy idea? Does it already exist? Who’s up for building it?

Subscribe Get Blog Posts in Your Email
Enter your email to receive new blog posts in email. 
icon

20 comments


  1. Anonymous says:

    Why not PowerShell?

    1. Are you kidding? I love PowerShell and Jeffery Snover is one of my heros. However, PowerShell has exactly the same problem: the OSS tools are built to run on Linux. They are ported to Windows via an API layer that has an impedence mis-match. Powershell will not help that.

      1. Scott says:

        I guess it’s time for MS to up their game on the OSS tools. There’s no good reason that at this point we should have to go to *NIX to build great OSS projects using great OSS tools. Of course I have given up on the cross platform thing.

  2. harold says:

    Colinux? 
    http://www.colinux.org/

    1. Thanks for pointing me at that.  Sounds like a super scary way to go. They are, effectively, building their own virtualization layer, but one that is specific for running the Linux kernel in ring 0 alongside the Windows kernel. I don’t see the advantage of doing it the way they are doing it.

  3. Anonymous says:

    Sounds like you’ve already figured out the best way to do this. Why do you need to run those command line tools on Windows? Just run them on Mac and use a shared filesystem.

    1. Did you read the 2nd line of the post? I have many reasons to still run Windows on some of my machines.

      1. Anonymous says:

        Yeah, cygwin sucks. Virtualbox seamless mode should get you most of what you want – i.e. the “opposite” of what you’re doing on your mac.

        If you wanted to build this to just expose the terminal, it would probably be easiest to use qemu. It runs on Windows and you can boot a minimal Linux very easily. Add in samba and you’ve got shared files. Now you’ve got a single terminal – no coding required.

        Assuming you want more than one terminal you would want X and an RDP client. This is a bit messier. Something like this, but the other way around: https://help.ubuntu.com/community/SeamlessVirtualization

        If that fails, you could just turn all your machines in to Hackintoshes and put Windows on top.

        1. I had forgotten VirtualBox had seamless mode.  Thanks!

          I’m missing how to :- Get rid of the stupid bar it leaves across the top of the screen (actually it’s Mint that’s doing this, so maybe a different distro or configuring Mint).- I don’t know how to map my Windows file system into it.  I’d rather not use SMB to do it for perf reasons…

          1. Progress!  Using this: 
            https://help.ubuntu.com/community/VirtualBox/SharedFolders

            Plus VirtualBox in Seamless mode.I now have a Linux terminal window were I can type
            cd ~/shared
            ls

            And see the contents of C:UsersCharlie on my Windows host!!!

            Now to figure out which Linux distro to use that has the least amount of crud.  I’m currently using MINT and the desktop in Seamless mode “shows through”.  I want a CLI only Linux that supports the VirutalBox extensions….

          2. Sean McLeod says:

            Although VirtualBox – SharedFolders are SMB/CIFS based, albeit “optimised”.

            “VirtualBox/SharedFolders describes sharing folders on the host with guests. This is the Virtual Box method, but others are available, such as standard samba, nfs, and using internet-based storage. The VirtualBox method is optimised Samba.”

          3. Dennis Hamilton says:

            Hmm, VirtualBox looks very interesting, especially because it will run x64 guests on my WIndows 7 Ultimate, something Virtual PC declines to do. 

            I’m more interested in OpenBSD/FreeBSD so I don’t expect the crud problem. 

            The integration with host applications is tricker though (since we’re asking the host to operate over the guest file system, yes? 

            Translating host file paths from the guest view to the host-app-required view seems to be tricky with regard to starting host apps with command-line parameters for files too.

            Cygwin doesn’t do this so well and SUA seems to muck it up completely unless there is a startup option I haven’t found.

            As long as VirtualBox has a rational way for the guest utilities to access and produce files on the host system (including \… locations), I can do what I need to do for interoperability testing of multi-platform code.

            Charlie, which parts of host guest interoperation are essention to your use case? 

  4. Dennis Hamilton says:

    To some degree SUA is supposed to do that, but more smoothly than cygwin.  It’s not virtual though and the porting of utilities might not do what you want. 

    This is something I hanker for a little bit, but I don’t think I have the chops to figure out how to do it from a VM and my explorations of SUA have not been deep enought to know if that provides an avenye.

  5. Sean McLeod says:

    In terms of mapping the Windows (host) file system you could use smbmount in the Linux guest.

    In terms of recognising Windows executables and having them launched from within zsh I guess you could modify zsh to detect when it’s being asked to execute a Windows executable (and have the Windows PATH added to your Linux PATH based on where you smbmount the filesystem) and in that case instead of trying to exec it, it would turn around and launch it via a proxy CreateProcess server running on the host passing the command line, current directory etc.

    Or I guess modify exec in Linux to have this detection logic and remote the request.

  6. Jay Palat says:

    Might I suggest Vagrant (vagrantup.com)?  It manages some of the interactions you’re looking for.  It runs VirtualBox in headless mode and you can ssh into the console.  It auto mounts the directory you load from, so running Vagrant from your home directory would allow you to access everything from the linux shell.  It doesn’t kick off the windows versions of things, but you could run the zsh as you wish.

    1. Wow, Jay, this looks good. I’m going to check it out when I get a chance. Thanks!

      1. I’ve found vagrantup.com to be a fantastic way to manage VirtualBox VMs on Windows. Slick as snot. Just worked.

        Now I need to figure out how to configure a distro with a super-minimal GUI (terminal only) + VirtualBox additions. 

  7. Anonymous says:

    Also checkout iTerm2 (http://www.iterm2.com), which is the successor to iTerm and has a whole host of awesome features– I just discovered instant reply, which is “Tivo for the Terminal”

  8. Anonymous says:

    This is pretty much exactly what you’re looking for… in theory. I couldn’t get it to work quite right. http://sourceforge.net/projects/freetzlinux/

  9. John Owens says:

    Echoing another poster below, it’s possible that SUA (formerly Interix) might do what you’re looking for. Its biggest gap is that it doesn’t include an X server, but you can get a native Windows one and use the SUA X clients, and it sounds like you’re most interested in command-line tools anyway. Unlike something like cygwin, which calls Win32, SUA runs as a peer to Win32 and can support different behavior, reducing the “impedance mismatch”.

    Info at http://technet.microsoft.com/en-us/library/cc772343.aspx
    and you’ll also need http://go.microsoft.com/fwlink/?LinkId=139521 .

    Here’s the “hub” with the best info and downloads on how to make real use of it: http://www.suacommunity.com/SUA.aspx .

    Hope this helps.

Debate this topic with me:

This site uses Akismet to reduce spam. Learn how your comment data is processed.