Created
July 17, 2018 10:06
-
-
Save nathanchere/3360f9f5e8249038f9d504a0d2456024 to your computer and use it in GitHub Desktop.
My powershell profile / prompt
This file contains hidden or 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
# 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