Tuesday, March 27, 2012

Git Bash

Since I've been using Linux, I find it painful to use the old cmd shell in Windows anymore. I've been using Windows for years, but never really got excited about the command line. When I made the switch to Unix, the command line became fun for me. I had full blown access to my computer using nothing but my keyboard. More impressively, I had full blown access to other (*nix) computers using nothing but my keyboard as well... all within the same terminal shell.

To me, it feels as though Unix made the command line it's foremost tool. Anything and everything can be done from the command line. In many cases, I've heard that many of the Unix applications actually interface with the kernel using command line calls to the various shell apps. Whereas, I feel that Microsoft really focused on giving most of it's power through various forms and dialogs. Most anything can be done inside the cmd prompt, I'm sure, but most of the functionality is taught and shared through the various user interface applications. Don't get me wrong!! There is great power there and it's very useful for most people! Hell, it's what I got started on; I respect my roots. :)

I never really appreciated the command line until I got my Mac. My buddy, Ben, showed me how much power Mac's have using nothing more than Terminal.app. All the sudden it became fun for me. I could open my Terminal app and punch in basic commands to make my computer do things. It was like programming my computer without using an IDE. It was very different from anything I was used to in Windows. Once the commands became natural to me, I began plugging them together using pipelines and so forth. At some point it all clicked and I realized how powerful the command line really was. The more I used it, the more I found myself customizing it to fit my needs. I could change colors, change my prompt, change the way I edited the command line, and so forth. I have all kinds of aliases defined that do some pretty sophisticated stuff with a few keystrokes.

What are my options for command line goodness on Windows though?

PuTTY is an old school terminal emulator for Windows. This tool is used more for logging into other computers though. It's not really intended for managing your local client machine. I'm sure there are ways to make it work this way, but it's not a good replacement for cmd in my opinion. This applications is how I was first introduced to Linux and SSH; it gave me a bad taste for Linux right away.

Console is a replacement for cmd, and I've not yet downloaded it. It sounds to me like it is more of a shell consolidator. Basically, it allows you to choose any shell that you want using a tabbed interface. So in "programming terms" it's more of a composite shell. :) This doesn't give me my Unix tool set though with all the customizations that I'm used to in Unix though... Again, I need to look into this more, but it's what I've gathered from my (minimal) research.

Cygwin is a set of tools that sit inside of the Windows cmd terminal (if I understand correctly). It allows you to manage your computer using all the same application names (ls, pwd, cd, etc..) but this isn't really a full blown replacement for bash; rather a set of tools that mask the cmd terminal with Unix like tools IMO. I'd much rather have a full blown version of the Bourne Again SHell sitting inside Windows 7 instead.

Along comes Git Bash for Windows.

When I installed msysgit, (the Git binaries for Windows), it came with a "Git Bash" shell. At first I thought it was another version for the PuTTY terminal emulator. However, the more I use it the more I realized that it's the real deal. It is (almost) exactly like having a Unix Bash Shell inside Windows finally. I use it for everything now. I open it up when I sit down to work and it stays open until I close my laptop. Best yet, I can secure shell into my *nix VM's and manage them remotely from Windows now. I no longer have to open up PuTTY to login to my VM's. I can grep, find, pipe, less, generate ssh keys, you name it. I can even customize the shell with a .bashrc file. For example, my command line editor is configured to use vim keybindings (ie. set -o vi)... IN WINDOWS!! It's great!

The one thing I can't do with this shell is sudo commands with administrative privileged. However, that's more of a Windows vs. Linux thing, rather than a bash shell feature. To get around this, I simply have to open another Bash shell "As Administrator" and perform my operations inside that shell. I don't mind this trade off.

By far, my favorite feature of having a bash shell in Windows is that I have full vi (pronounced "vee eye") editing capabilities on any text file. I'm finding it harder and harder to live without this single feature.

There you have it... Check it out. Git Bash for Windows is the cats pajamas.

1 comment:

Anonymous said...

Thanks you for this!!