Learn-a-holic Geek Notes

Human compiled Brainwork by Kornelije Sajler.

Make Powershell, SSH Github and Git Suck Less on Windows

There are two Terminals in Windows Command Prompt and Powershell, and they both suck by far. I can understand that Command Prompt is no good, but why the Powershell wasn’t done better?!

The things missing in Powershell:

  • Maximizing is just so mid ‘90.
  • History for a session only (So annoying).
  • Painful adding of Aliases.
  • Emacs navigation (Ctrl+a,Ctrl+e,…).
  • Full screen and Tranparency (Oh I just want too much).
  • The config dir is in Documents\WindowsPowerShell (WTF).

Maybe to most Windows users this is strange because this kind of stuff is never used, but if you’re coming from Linux or Mac then the frustration is certain. Because Linux or Mac are having great Terminal and working in them is just a joy.

The aim of post is to install git on Windowns and then configure it. Then customize a little bit the Powershell because the defaults are just crime against humanity. Configure SSH on machine and register SSH key with Github. Install must-have posh-git that will add the branch/status to Powershell prompt plus auto-completion for git.

Note that I’m using Windows 8 and Powershell version 3.0.

Git Install

For those who might don’t know the git is created by Linus Torvalds the creator of Linux Kernel. Git was a product of his frustration maintaining Linux Kernel. He is not really the huge fan of Windows (nor am I) so git Windows implementation was hard to do because it really relies on Unix/Linux commands and philosophies that are lacking on Windows.

I know there was a problem I while back with the official Git version for Windows and I was always using the msysgit, don’t know if still is the case but I will use msysgit in this post.

Download the latest msysgit and install it with just clicking next few times. There are few things to configure, but using defaults is safest way.


There is also a Github for Windows. Probably even easier way to install and configure git on Windows, but I like to complicate things.

Add Git to PATH

By default the git binaries are not set in to PATH, so add it by going to:

Control Panel/System and Security/System/Advanced system settings

Then in System Properties click on Environment Variables… and in System Variables list box scroll to Variable Path, double-click it and add at the end:

;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;

Test that the git is available by opening the Powershell. Easiest way to open te Powershell (if there is no shortcut) especially in Windows 8 is Win+r and type powershell to prompt.

In Powershell type:

C:\> git
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [-c name=value] [--help]
           <command> [<args>]


If you get something like usage: git, then the git is ready!

Configure Git

Set the user name that will be readable in git log or history:

C:\> git config --global user.name "Kornelije Sajler"

Then set your email:

C:\> git config --global user.email "xajler@gmail.com"


Your email address for Git should be the same one associated with your GitHub account.

Generate SSH key

With msysgit comes a Git Bash needed to generate SSH keys. If you have one skip this step!

To open Git Bash right-click on any folder in Windows Explorer and choose Git Bash. In Git Bash enter:

$ ssh-keygen -t rsa -C "xajler@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Kornelije/.ssh/id_rsa):

Keygen will ask you for passphrase. In my first attempt I’ve added one, but on each commit I have to enter passphrase. That is so annoying.

If you have a SSH key passphrase and it annoys you then enter:

$ ssh-keygen -p

It will ask you for current passphrase, enter the current passphrasse, and with two enters, you’ll now have a blank passphrase!

Git Bash Copy/Paste

The copy/paste is so awful in Git Bash. To paste you need to click the icon in top left corner, go to Edit then Paste.

The copy is even more cumbersome, I’ll just give you a hint, choose Select All!

Or read at the end in Options Tab part of Powershell Customization to enable QuickEdit Mode.

Set SSH key to Github

To set the public SSH key in Github there is need for getting it from a ~/.ssh/id_rsa.pub.

Again open Git Bash right-click on any folder in Windows Explorer and choose Git Bash. In Git Bash enter:

$ clip < ~/.ssh/id_rsa.pub

This command will copy your public SSH key to clipboard. Then go to Github / Account Settngs / SSH Keys and click the button Add SSH Key.

Enter Title (sorry about my title):


Enter Key:

Just paste from clipboard

By clicking Add Key you have successfully added SSH key to Github and the git pushing to Github is now super easy.

Powershell customization

The visual features of Powershell probably didn’t change since Windows 95, and defaults are probably still dating from ‘95 and selecting, copy, pasting is awkward, hard and unusable!

Suck less Powershell

Click the small Powershell icon in top left corner, and in the context menu click on Properties.

Options Tab

In Edit Options check the QuickEdit Mode. Quick edit mode enables selecting text from anywhere in Powershell and with right-click it will copy the selected content. Also with single right-click pastes the text where the blinking cursor currently is, similar to putty.

This option really boosts the productivity in Powershell, it is too bad that this is not set by default!

Font Tab

Even we are in 21st century but the Powershell is still set by default to Raster Fonts with awkward sizes like 16x12, 6x8, that I never really get the meaning of.

In Font list choose the Consolas font (or other available mono-space font) and you can check the Bold fonts if you like to have bold text. As for Size in list choose whatever you want I’ll stick to 18.

Layout Tab

The Powershell by default is very small, at least to me, maximize is totally unusable, there is no full screen!

Screen Buffer Size and Window Position Width height should be same size if you dont want to have ugly horizontal scroll bar. I set Width to 125 and Window Position Height to 35.

This are all customization, it is not too much but Powershell suck a little less after it, but there is a room for lots and lots of improvements, while Microsoft spends time on useless technologies like Light Switch.

Posh-Git: Make your Git shine in Powershell

A set of Powershell scripts which provide Git/PowerShell integration. Includes:

  • Prompt for Git repositories - shows the current branch and the state of files (additions, modifications, deletions) within.
  • Tab completion for git commands.


Clone it from Github to any folder, I’ll clone it in source folder:

C:\source > git clone git://github.com/dahlbyk/posh-git.git

Verify execution of Powershell scripts is allowed with:

C:\source > Get-ExecutionPolicy

The result should be RemoteSigned or Unrestricted.

If scripts are not enabled, run Powershell as Administrator and call:

C:\source > Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm

Then cd to posh-git folder and run:

C:\source\posh-git > .\install.ps1
Creating PowerShell profile...
Adding posh-git to profile...
posh-git successfully installed!
Please reload your profile for the changes to take effect:
    . $PROFILE

Then reload your profile, as noted in posh-git after install note:

C:\source\posh-git > . $PROFILE

If you’re done everything from this post then everything should work just fine!

The outcome of whole post is to have something at the end of the day:

And just for comparison the Terminal iTerm2 on my Mac OS X Mountain Lion with zsh shell and very short aliases, pure awesomeness: