I never used to be a fan of the command line.
Coming from a graphical background – and being so used to the GUI on Windows – using a text-only interface is extremely foreign. That said, it’s also very consistent, fast, and powerful.
For the past couple of months, I’ve been moving between Windows and Mac on an almost daily basis. I have a Windows machine for use at home, and a Mac that I use when I’m in the office, on the road, on the bus, in the other room, waiting for dinner … you get the idea. While the operating systems might be incredibly different, they’re also very much the same.
*Nix Command Line
If you’ve been keeping tabs on WordPress development, you’ll know the cool, new kid of the block is Vagrant. I spin up a new virtual machine for each and every project – all of which run Linux. The *nix command line is fantastic for rapidly finding files, running Git commands, connecting to remote machines over SSH, etc.
Also, thanks to Vagrant, the command line is identical on both my Windows and Mac machines. Easy.
Once I switched to Vagrant, I started removing all of the server tools I had installed on my Windows machine. No more MySQL. No more Apache. No more PHP. My filesystem is much cleaner, my machine is much faster. I still have Node, Ruby, and Grunt running locally for my development environment, but all of the heavier server-esque software has been thoroughly eliminated.
When I set up my Mac, I was intent on installing the bare minimum I needed for development. Once again, Node, Ruby, and Grunt run locally. Along with Git and Subversion for version control. Again, Easy. Well, except for one tiny detail.
The Mac OS is a *nix architecture, meaning it has all of the cool command line tools I have on Vagrant. Windows doesn’t.
Linux Tools … on Windows
When you first install Vagrant on Windows, you’ll get an error at the end claiming you can’t SSH in to your new virtual machine. 1 I found this annoying and was happy to use a few workarounds for a while. But my Mac friends had far more streamlined environments, and I felt left out.
My first attempt was to use Cygwin to install some additional tools. If you’re thinking about doing this, don’t. I can’t express in any stronger terms: if you’re trying to keep your development environment clean and streamlined, Cygwin is not the tool for you. I learned the hard way, and went back to my messy workarounds.
Then one day I remembered something – Git has SSH.
I dug in to the files Git installed 2 on my machine when I first set things up:
It turns out, Git bundles most of the *nix tools I use on a daily basis already! All I had to do was map the Git’s
/bin directory to my system path and, voila!
Now, I can use the exact same commands on my Windows machine as I use on my Mac to interact with servers over SSH, pull down files with cURL, securely copy database dumps with scp. You name it! The only thing lacking was Vim, the text editor I use to quickly edit configuration files and the like from the command line.
Adding Vim Support
Luckily, Vim does come with Git, but it’s shipped in such a way as to only work with Git’s bundled Bash shell. I don’t like switching from the Windows command line to Bash needlessly, so I wanted a native workaround for using a quick editing tool.
Like installing *nix tools themselves, this turned out to be easy as well. I added a quick batch file to the
/bin directory within Git that merely passes through any Vim command line arguments from the Windows command line through to the Vim executable:
"C:\Program Files (x86)\Git\share\vim\vim73\vim.exe" %*
If you follow the advice above, you too can benefit from having amazingly powerful *nix-style tools available from the Windows command line. Just more proof that you can be a serious application developer and use Windows at the same time.