Skip to content

Instantly share code, notes, and snippets.

@joonro
Last active August 29, 2015 14:25
Show Gist options
  • Save joonro/e6c54c033069a0ecb67a to your computer and use it in GitHub Desktop.
Save joonro/e6c54c033069a0ecb67a to your computer and use it in GitHub Desktop.
Import-Module posh-git
# customize git prompt display settings
$global:GitPromptSettings.BeforeText = '['
$global:GitPromptSettings.AfterText = '] '
$global:GitPromptSettings.BranchAheadForegroundColor = [ConsoleColor]::Green
$global:GitPromptSettings.WorkingForegroundColor = [ConsoleColor]::Magenta
$global:GitPromptSettings.UntrackedForegroundColor = [ConsoleColor]::DarkGray
Enable-GitColors
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
Write-Host
# Reset color, which can be messed up by Enable-GitColors
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
if (Test-Administrator) { # Use different username if elevated
Write-Host "(Elevated) " -NoNewline -ForegroundColor White
}
Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor DarkYellow
Write-Host "$ENV:COMPUTERNAME" -NoNewline -ForegroundColor Magenta
if ($s -ne $null) { # color for PSSessions
Write-Host " (`$s: " -NoNewline -ForegroundColor DarkGray
Write-Host "$($s.Name)" -NoNewline -ForegroundColor Yellow
Write-Host ") " -NoNewline -ForegroundColor DarkGray
}
Write-Host " : " -NoNewline -ForegroundColor DarkGray
Write-Host $($(Get-Location) -replace "C:\\Users\\Joon", "~") -NoNewline -ForegroundColor Blue
Write-Host " : " -NoNewline -ForegroundColor DarkGray
Write-Host (Get-Date -Format G) -NoNewline -ForegroundColor DarkMagenta
Write-Host " : " -NoNewline -ForegroundColor DarkGray
$global:LASTEXITCODE = $realLASTEXITCODE
Write-VcsStatus
Write-Host ""
return "> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment