Posh Git

I have tried to get my head around PowerShell for a while, and I’ve read blogs by Scott Hanselman about PsReadline and PoshGit and decided to finally get on with it and use it properly.

This post is just a repository of my current setup.

Install PsGet if you don’t have it:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex

Install PsReadline:

Install-Module PsReadline

Install Git for Windows


Install posh-git

Install-Module posh-git

Update the profile.ps1 file

Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)

# Load posh-git module from current directory
Import-Module PSReadLine
Import-Module posh-git

# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
# Import-Module posh-git

# Set up a simple prompt, adding the git prompt parts inside git repos
function global:prompt {

 # Reset color, which can be messed up by Enable-GitColors
 $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor

 Write-Host($pwd.ProviderPath) -nonewline


 return "> "



Start-SshAgent -Quiet

set-alias -name np -value "C:\Program Files\Sublime Text 2\sublime_text.exe"

function vsh() {
 Write-Output "Opening first solution..."
 $sln = (dir -in *.sln -r | Select -first 1)
 Write-Output "Found $($sln.FullName)"
 Invoke-Item $sln.FullName
function title($str) {
 (get-host).ui.rawui.windowtitle = $str
function ga() {
 Write-Output "Staging all changes..."
 git add -A
 git status

function gs() {
 git status

function gsd() {
 Write-Output "Pushing changes to subversion..."
 git svn dcommit

function gsf() {
 Write-Output "Checking subversion for recent changes..."
 git svn fetch
function gco() {
 param([switch]$amend, [switch]$a)
 $argstr = $args -join ' '
 $message = '"', $argstr, '"' -join ''
 if ($amend -or $a) {
 Write-Output "Amending previous commit with message: $message"
 git commit -m $message --amend
 } else {
 Write-Output "Committing with message: $args"
 git commit -m $message
function gca() {
 $argstr = $args -join ' '
 $message = '"', $argstr, '"' -join ''
 Write-Output "Amending previous commit with message: $message"
 git commit -m $message --amend


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