Skip to content

Instantly share code, notes, and snippets.

@pauby
Created August 14, 2018 08:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pauby/6e8f8b6203512b6073965be0305135f6 to your computer and use it in GitHub Desktop.
Save pauby/6e8f8b6203512b6073965be0305135f6 to your computer and use it in GitHub Desktop.
function prompt {
# https://github.com/dahlbyk/posh-git/wiki/Customizing-Your-PowerShell-Prompt
$realLASTEXITCODE = $LASTEXITCODE
Write-Host
if ($PSVersionTable.PSEdition -eq 'Core') {
Write-Host '(Core) ' -NoNewline
}
write-host "[" -noNewLine
write-host $(get-date -format "dd/MM hh:mmtt") -foreground yellow -noNewLine
write-host "] [" -noNewLine
Write-Host "$ENV:USERNAME@" -NoNewline -ForegroundColor DarkYellow
Write-Host "$ENV:COMPUTERNAME" -NoNewline -ForegroundColor Magenta
write-host "]" -noNewLine
Write-VcsStatus
Write-Host " " -NoNewline
Write-VagStatus
Write-Host " " -NoNewline
try {
$history = Get-History -ErrorAction Ignore
if ($history) {
Write-Host "[" -NoNewline
$diff = $history[-1].EndExecutionTime - $history[-1].StartExecutionTime
$firstOne = $true
$executionTimeDisplay | ForEach {
if ($diff.$($_.time) -gt 0) {
if (-not $firstOne) {
Write-Host " " -NoNewline
}
Write-Host "$($diff.$($_.time))$($_.display)" -NoNewline
$firstOne = $false
}
}
Write-Host "] " -NoNewline
}
}
catch {}
Write-Host $($(Get-Location) -replace ($env:USERPROFILE).Replace('\', '\\'), "~") -NoNewline -ForegroundColor Cyan
$global:LASTEXITCODE = $realLASTEXITCODE
Write-Host ""
return "> "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment