Created
May 2, 2012 14:01
-
-
Save nberardi/2576719 to your computer and use it in GitHub Desktop.
Nick Berardi's PowerShell Profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################### | |
# global variables | |
############################################################################### | |
$profileDir = [System.IO.Path]::GetDirectoryName($profile) | |
############################################################################### | |
# Set up a simple prompt, adding the git prompt parts inside git repos | |
############################################################################### | |
function prompt { | |
$realLASTEXITCODE = $LASTEXITCODE | |
Write-Host | |
# Reset color, which can be messed up by Enable-GitColors | |
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor | |
Write-VcsStatus | |
Write-Host($pwd) -ForegroundColor Green | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
return "$ " | |
} | |
############################################################################### | |
# Exposes the environment vars in a batch and sets them in this PS session | |
############################################################################### | |
function Get-Batchfile($file) | |
{ | |
$theCmd = "`"$file`" & set" | |
cmd /c $theCmd | Foreach-Object { | |
$thePath, $theValue = $_.split('=') | |
Set-Item -path env:$thePath -value $theValue | |
} | |
} | |
############################################################################### | |
# Sets the VS variables for this PS session to use | |
############################################################################### | |
function VsVars32($version = "10.0") | |
{ | |
$theKey = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version | |
$theVsKey = get-ItemProperty $theKey | |
$theVsInstallPath = [System.IO.Path]::GetDirectoryName($theVsKey.InstallDir) | |
$theVsToolsDir = [System.IO.Path]::GetDirectoryName($theVsInstallPath) | |
$theVsToolsDir = [System.IO.Path]::Combine($theVsToolsDir, "Tools") | |
$theBatchFile = [System.IO.Path]::Combine($theVsToolsDir, "vsvars32.bat") | |
Get-Batchfile $theBatchFile | |
[System.Console]::Title = "Visual Studio " + $version + " Windows Powershell" | |
} | |
############################################################################### | |
# aliases | |
############################################################################### | |
set-alias wide format-wide | |
############################################################################### | |
# functions | |
############################################################################### | |
set-content function:\mklink "cmd /c mklink `$args" | |
############################################################################### | |
# setup posh-git | |
############################################################################### | |
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) | |
# add Git to PATH | |
$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin" | |
# import posh-git | |
Import-Module posh-git | |
# customize git prompt display settings | |
$global:GitPromptSettings.BeforeText = '[' | |
$global:GitPromptSettings.AfterText = '] ' | |
$global:GitPromptSettings.BranchAheadForegroundColor = [ConsoleColor]::DarkGreen | |
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Magenta | |
$global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::Magenta | |
# set TERM to cygwin | |
Enable-GitColors | |
Pop-Location | |
Start-SshAgent -Quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment