Last active
March 14, 2019 10:41
-
-
Save MaxMelcher/5d4869738d7f27c3e3f6684c4fa81040 to your computer and use it in GitHub Desktop.
Powershell prompt to show execution time and git status based on two gists: https://gist.github.com/kilasuit/8f17db5a0825f3cdaa315385456e7f7e https://gist.github.com/amandadebler/d4856e307e7c020f14312b9412493aea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Prompt { | |
try { | |
$history = Get-History -ErrorAction Ignore -Count 1 | |
if ($history) { | |
Write-Host "[" -NoNewline | |
$ts = New-TimeSpan $history.StartExecutionTime $history.EndExecutionTime | |
switch ($ts) { | |
{$_.TotalSeconds -lt 1} { | |
[int]$d = $_.TotalMilliseconds | |
'{0}ms' -f ($d) | Write-Host -ForegroundColor Black -NoNewline -BackgroundColor DarkGreen | |
break | |
} | |
{$_.totalminutes -lt 1} { | |
[int]$d = $_.TotalSeconds | |
'{0}s' -f ($d) | Write-Host -ForegroundColor Black -NoNewline -BackgroundColor DarkYellow | |
break | |
} | |
{$_.totalminutes -lt 30} { | |
[int]$d = $ts.TotalMinutes | |
'{0}m' -f ($d) | Write-Host -ForegroundColor Gray -NoNewline -BackgroundColor Red | |
break | |
} | |
Default { | |
$_.Milliseconds | Write-Host -ForegroundColor Gray -NoNewline | |
} | |
} | |
Write-Host "]" -NoNewline | |
} | |
if(Get-Module Posh-git) {Write-VcsStatus} | |
} | |
catch { } | |
# show the drive and then last 2 directories of current path | |
if (($pwd.Path.Split('\').count -gt 2)){ | |
write-host "$($pwd.path.split('\')[0], '...', $pwd.path.split('\')[-2], $pwd.path.split('\')[-1] -join ('\'))" -NoNewline | |
} | |
else{ | |
Write-Host "$($pwd.path)" -NoNewline | |
} | |
"> " | |
} | |
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-9bda399\src\posh-git.psd1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment