feanz
8/18/2014 - 4:13 PM

Powersehll profile

Powersehll profile

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

# Load posh-git module from current default module locaiton
Import-Module posh-git


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

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

    Write-Host($pwd.ProviderPath) -nonewline

    Write-VcsStatus

    $global:LASTEXITCODE = $realLASTEXITCODE
    return "> "
}

function gh{
	
	$url = & git config --get remote.origin.url
    $url = $url.TrimEnd(".git")
    $branch = & git symbolic-ref HEAD 
    Write-Host "On Branch" $branch
    $branch = $branch.Substring(11,($branch.length-11))
    Write-Host $branch
    $url = $url.ToString() + "/tree/" + $branch.ToString()
	
    Write-Host "Opening" $url
    
    [System.Diagnostics.Process]::Start($url)
    return
}

function gh-pull{
	
	$url = & git config --get remote.origin.url
    $url = $url.TrimEnd(".git")
    $url = $url.ToString() + "/pulls"
	
    Write-Host "Opening" $url
    
    [System.Diagnostics.Process]::Start($url)
    return
}

Enable-GitColors

Pop-Location

Start-SshAgent -Quiet