Setting up a Unix environment in Windows

TL;DR :

  • Get consolez
  • get cygwin, and apt-cyg
  • Map windows’ version of software so they can be run in the shell. e.g. vim

This post will talk about how I set up my Windows development console and how it integrates nicely with a Unix workflow.

My laptop’s hardware incompatibility (overheating GPU and a non-working fingerprint reader) when running Linux is the main motivation for this setup. I find that the Unix terminal is more conducive for programming than the Windows’ terminal for some reasons. So because I am stuck with using Windows for now, I really like being able to emulate a Unix environment as much as possible.

Most common way to do so is to install a Unix environment such as cygwin or mingw, or if you install git, you’ll have git bash. However, these are quite spartan and feels more like a clutch rather than a proper tool. I also wanted to be able to use tabs and have my home directory similar to that of Windows. In short, I wanted those terminals to be a drop-in replacement for cmd.

Then I found console. Firstly, it has tabs, which makes things awesome (aside: It really amazes me that tabbed windows explorer isn’t a thing even up till Windows 8, when tabbed browsers was already a thing as early as Windows XP). Secondly, it allows you to launch different types of shell, both cmd and those terminals mentioned above. That is great because now I can bind a shortcut key like ctrl + alt + t to launch console, and go into a Unix environment. Later on I found a fork of console called consolez, which has many awesome features like keybinding for hiding/revealing the console, running cmd with elevated privileges, windows snap. The last one means I can break out of the 80 by 25 window, which makes vim look awesome.

However, such emulators fall short of the Unix terminal because not all POSIX softwares are available by default, eg ssh. Furthermore, installing a software on such terminal is not as simple as apt-get install <package> in Linux. Luckily, for cygwin, there is apt-cyg, which allows you to install software by typing apt-cyg install <package>.

Still, that is not a silver bullet, some software deals with the windows libraries and the above method just doesn’t work. In that case, a simple solution will be to install the windows binary version, and then copy the executable file into the /usr/bin directory for the terminal.

For example, I wanted to run mysql console from cygwin. But it was not installed by default. Using apt-cyg install mysql gave me some error when running it which I suspect is because the system calls don’t match up exactly between the two environment. However, because I already have mysql installed via wamp, I simply copied the binary from wamp/bin/mysql/mysql<version>/bin to cygwin/bin and viola, I was able to run mysql inside cygwin successfully.

That concludes this post. This has made my life working in the command line so much more pleasurable in Windows.

Advertisements

Published by

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