Skip to content

Instantly share code, notes, and snippets.

@thoemmi
Created September 14, 2012 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoemmi/3720721 to your computer and use it in GitHub Desktop.
Save thoemmi/3720721 to your computer and use it in GitHub Desktop.
my PowerShell profile script
# red background if running elevated
& {
$wid=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp=new-object System.Security.Principal.WindowsPrincipal($wid)
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin=$prp.IsInRole($adm)
if ($IsAdmin)
{
(get-host).UI.RawUI.Backgroundcolor="DarkRed"
clear-host
}
}
$profileFolder = split-path $profile
# save last 100 history items on exit
$historyPath = Join-Path $profileFolder history.clixml
# hook powershell's exiting event & hide the registration with -supportevent.
Register-EngineEvent -SourceIdentifier powershell.exiting -SupportEvent -Action {
Get-History -Count 100 | Export-Clixml (Join-Path (split-path $profile) history.clixml) }
# load previous history, if it exists
if ((Test-Path $historyPath)) {
Import-Clixml $historyPath | ? {$count++;$true} | Add-History
Write-Host -Fore Green "`nLoaded $count history item(s).`n"
}
Import-Module "PowerTab" -ArgumentList "$profileFolder\PowerTabConfig.xml"
# Load posh-git example profile
. "$profileFolder\Modules\posh-git\profile.example.ps1"
# Modifying text color for posh-git
# see http://sedodream.com/2012/05/05/GitCustomizingColorsForWindowsIncludingPoshgit.aspx
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Yellow
$global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::Yellow
#Set environment variables for Visual Studio Command Prompt
pushd "$env:VS110COMNTOOLS..\..\VC"
cmd /c "vcvarsall.bat&set" |
foreach {
if ($_ -match "=") {
$v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"
}
}
popd
write-host "`nVisual Studio 2012 Command Prompt variables set." -ForegroundColor Yellow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment