Skip to content

Instantly share code, notes, and snippets.

@nestalk
Last active June 20, 2018 08:43
Show Gist options
  • Save nestalk/c40797f98e80d2b2848e to your computer and use it in GitHub Desktop.
Save nestalk/c40797f98e80d2b2848e to your computer and use it in GitHub Desktop.
My poshgit prompt
# Load posh-git example profile
if(Test-Path Function:\Prompt) {Rename-Item Function:\Prompt PrePoshGitPrompt -Force}
Import-Module 'D:\Development\posh-git\src\posh-git.psd1'
Start-SshAgent -Quiet
function Prompt() {
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $windowsIdentity
if ($psISE) { $color = "Black"; }
elseif ($windowsPrincipal.IsInRole("Administrators") -eq 1) { $color = "Red"; }
else { $color = "Green"; }
# write directory location on its own line
Write-Host $(Get-Location) -ForegroundColor Magenta -NoNewLine
# write the git status
Write-VcsStatus
write-host ">" -ForegroundColor Magenta
# show the location stack count
if ((get-location -stack).Count -gt 0) {
write-host (("+" * ((get-location -stack).Count))) -NoNewLine -ForegroundColor Cyan
write-host " " -NoNewLine
}
# show the propt, green if user, red if admin
write-host "$" -NoNewLine -ForegroundColor $color
return " "
}
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment