Skip to content

Instantly share code, notes, and snippets.

@9point6
Last active August 29, 2015 14:08
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 9point6/a622c87ea8e72339c9cd to your computer and use it in GitHub Desktop.
Save 9point6/a622c87ea8e72339c9cd to your computer and use it in GitHub Desktop.
PowerShell Profile
if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$bckgrnd = "DarkRed"
$shellchar = "#"
} else {
$bckgrnd = "DarkBlue"
$shellchar = "$"
}
$Host.UI.RawUI.BackgroundColor = $bckgrnd
$Host.UI.RawUI.ForegroundColor = 'White'
$Host.PrivateData.ErrorForegroundColor = 'Red'
$Host.PrivateData.ErrorBackgroundColor = $bckgrnd
$Host.PrivateData.WarningForegroundColor = 'Magenta'
$Host.PrivateData.WarningBackgroundColor = $bckgrnd
$Host.PrivateData.DebugForegroundColor = 'Yellow'
$Host.PrivateData.DebugBackgroundColor = $bckgrnd
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = $bckgrnd
$Host.PrivateData.ProgressForegroundColor = 'Cyan'
$Host.PrivateData.ProgressBackgroundColor = $bckgrnd
Clear-Host
Set-Alias sublime 'C:\Program Files\Sublime Text 3\sublime_text.exe'
# Enable Modules
Import-Module Posh-Git
Import-Module 'C:\bin\oneget\OneGet.psd1'
function prompt
{
$realLASTEXITCODE = $LASTEXITCODE
if ($?) {
$color = "Green"
} else {
$color = "Red"
}
$dir = $(pwd).path
if ($dir.length -gt 30) {
$dir = $(Split-Path -leaf -path (Get-Location))
}
Write-Host ("[" + $(Get-Date -UFormat %H:%M) + "]") -nonewline -foregroundcolor Magenta
Write-Host ("[" + $(@(Get-History).count) + "]") -nonewline -foregroundcolor Cyan
Write-Host ("[" + $(@(get-job).count) + "]") -nonewline -foregroundcolor Yellow
Write-Host ("[$Env:username@$Env:COMPUTERNAME]") -nonewline -foregroundcolor DarkCyan
Write-VcsStatus # Posh-Git
Invoke-Expression 'Write-Host ("`n[$dir] PS$shellchar") -nonewline -foregroundcolor $color'
$global:LASTEXITCODE = $realLASTEXITCODE
return " "
}
# Post-Git
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