Skip to content

Instantly share code, notes, and snippets.

@nathanchere
Created July 17, 2018 10:06
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 nathanchere/3360f9f5e8249038f9d504a0d2456024 to your computer and use it in GitHub Desktop.
Save nathanchere/3360f9f5e8249038f9d504a0d2456024 to your computer and use it in GitHub Desktop.
My powershell profile / prompt
# Requires nerdfont to display correctly
Import-Module posh-git
start-sshagent
function Test-Administrator {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
$GitPromptSettings.DefaultForegroundColor = 'White'
$GitPromptSettings.BeforeText = " [  "
$GitPromptSettings.BeforeForegroundColor = 'DarkGray'
$GitPromptSettings.AfterForegroundColor = 'DarkGray'
$GitPromptSettings.AfterText = ' ] '
$GitPromptSettings.FileAddedText = ''
$GitPromptSettings.FileModifiedText = ''
$GitPromptSettings.FileRemovedText = ''
$GitPromptSettings.FileConflictedText = ''
$GitPromptSettings.BranchIdenticalStatusToSymbol = ''
$GitPromptSettings.BranchForegroundColor = 'DarkGray'
$GitPromptSettings.BranchIdenticalStatusToForegroundColor = 'DarkGray'
$GitPromptSettings.LocalWorkingStatusForegroundColor = 'Blue'
$GitPromptSettings.LocalWorkingStatusSymbol = ''
function prompt {
$realLASTEXITCODE = $LASTEXITCODE
Write-Host
$Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
Write-Host "[ " -NoNewline -ForegroundColor DarkGray
Write-Host $(Get-Location) -NoNewline -ForegroundColor Gray
Write-Host " ] " -ForegroundColor DarkGray -NoNewline
$global:LASTEXITCODE = $realLASTEXITCODE
Write-VcsStatus
Write-Host
Write-Host " (" -NoNewline -ForegroundColor White
if (Test-Administrator) { # Use different username if elevated
Write-Host " Admin " -NoNewline -ForegroundColor White
}
Write-Host "" -NoNewLine -ForegroundColor Green
Write-Host ")" -NoNewline -ForegroundColor White
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment