Cross-Platform productivity with windows

I’ve tried before to set up a windows workstation so that I could get the best out of both worlds when it comes to productivity, but I’ve always had less than stellar results. It’s tough enjoying working on both sides of the technology fence. For the first time ever though I have found a successful set up that allows me the majority of the tools I had become accustomed to using in a fairly agnostic fashion.

Before I get into the details though here is a list of the tools I will be using:

What exactly is the end game

When I set out on this little adventure I wanted to be able to do these things:

  • better usable windows command prompt.
  • The ability to run Powershell and Unix tools from that command prompt.
  • The ability to code in a nice cross-platform editor.
  • The ability to test *nix applications from my windows desktop.

That’s a pretty tall order, even if you were to try as recent as six months ago half the tools I am going to be using didn’t exist or were not in a usable state. Each of the tools listed above provides us with a piece of this puzzle. Cmder provides us with the command line functionality, Atom gives us a very cool cross-platform editor and Boot2Docker allows us to easily build containerised Linux apps for testing our code.

Configuring Cmder

Apart from making our command prompt very pretty, cmder comes with a number of other great tools like the msysgit package which gives you command line git in windows as well as a whole bunch of unix tools (grep, cp, vim, more, less, etc), the ConEmu package provides the replacement terminal functionality and clink provides read line functionality but we won’t be needing that as you will see later!

Once you have downloaded, installed and opened Cmder, open the options menu by clicking the three bar symbol in the bottom right > settings…

There are a lot of options here to have a play with so that you can get things set up juuuust right for you. You will notice when you opened cmder that it will open a default windows command prompt which is nice, but you know what I love? Powershell. So I’m interested in configuring it so that when we open it up that it will bring us to a nice Powershell terminal with all the cool stuff still available.

Navigate in the options menu to Startup > Tasks, in the center of this panel you should see two options {cmd} and {PowerShell}, unfortunately the Powershell provided out of the box is a little bit rudimentary. I’ve created a new Powershell init script that you can find here that provides all of the functionality that is available to the command prompt version as well as PsGet which provides chocolatey package management for Powershell modules.

Once you have copied the init.ps1 script to your cmder/vendor directory then go back to the settings > Startup > Tasks screen in cmder and click the + button found at the bottom of the center panel. Call this new option whatever you want, I personally called it “pscmdr” and then set the options as follows:

  • Task Parameters: /dir “%userprofile%”
  • Commands: powershell  -NoLogo -NoExit -File “%ConEmuDir%..init.ps1”

It should look like:

Cmder1

Once that is done go up one level in the options menu to the Startup page and change the startup options so that they specify Specified named task: see the below screenshot as an example:

Cmder2

You may notice the first run is slow and takes a few seconds. You are now done configuring both Atom and Cmder, just Docker to go!

Installing Atom

Atom is an awesome editor that provides a really easy to use plugin system that makes it highly extensible. Once you have installed atom I would recommend installing a few of the below packages. Atom has a number of packages out of the box such as syntax highlighting for common languages like bash or python.

  1. Go to the settings menu click File > Settings in the top left hand corner of Atom.
  2. Select Packages from the left hand menu and use the search tool to install the following packages that are relevant to you (these are all optional, these are just my favourites):
  •  Language Batch - Syntax highlighting for windows batch files.
  • Language Powershell - Syntax highlighting for Powershell files.
  • File Icons - Gives files in the explorer a little icon so you can tell at a glance what kind of file it is.
  • Linter Jsonlint - Allows you to easily find errors in JSON files.
  • Language Docker - Syntax highlighting for Docker files.
  • Terminal Panel - Gives you a quick hotkey for opening a small terminal panel that is perfect for git commands without leaving your code window.

Installing Boot2Docker

If you haven’t heard of Docker yet you are in for a real treat, Docker is a containerisation tool for Linux which is a fancy way of saying it produces something like a lightweight VM. It’s important to note though that it is NOT a VM and is an isolated sandbox of processes that runs on a Linux machine. Docker allows you to bake these process sandboxes into an image which will then allow you to run whatever was baked into that image consistently anywhere. If you want to learn more about Docker then take a look at the website.

This isn’t an entirely new concept mind you and has been around in the unix world for a very long time, see AIX WPAR’s, HP-UX Containers or Solaris Zones, the real difference here is how easy the Docker tooling makes this functionality to use.

Boot2Docker is a package for Windows and Mac OSX that installs and configures a Virtual Box instance with a lightweight Linux image for running Docker containers on. After you have downloaded Boot2Docker you will want to follow their instructions for installing it.

Once you have it all set up and have successfully connected to the VM you can cd to /Users and after doing an ls you should be able to see all of the files in your windows desktop home directory. This hopefully allows you to get to your code directory so that you can build Docker images for testing your apps or so that you can import those directories directly into the Docker container itself while you are still building the app.

How to use Docker containers falls well outside the scope of this post as it would be an entire series in and of itself, but have a look at this handy tutorial for learning a bit more about it.

Done.

I’ve been using this combination of tools for the better part of a few weeks now and every now and then I will actually forget that I’m not using a *nix terminal and try to export ENVTHING=blah and then get a poignant Powershell red text reminder that I’m in the wrong window. Hopefully you find this as useful as I have!

comments powered by Disqus