Skip to content

Instantly share code, notes, and snippets.

@virtualex-itv
Forked from pauby/prompt.ps1
Last active April 16, 2019 18:26
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 virtualex-itv/55bf288f788fc44be2d307b603985b03 to your computer and use it in GitHub Desktop.
Save virtualex-itv/55bf288f788fc44be2d307b603985b03 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 "MM/dd/yy hh:mmtt") -ForegroundColor DarkGreen -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