Created
May 23, 2018 19:49
-
-
Save omniomi/895dadedbb385642cf4f3309bd24f591 to your computer and use it in GitHub Desktop.
PowerShell 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
| # Needs a Powerline Font (ie, DejaVu Sans Mono for Powerline). | |
| # Needs Posh-Git module. | |
| Import-Module Posh-Git | |
| $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) | |
| if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { $Script:IsAdmin = $true } | |
| function prompt { | |
| if (((Get-Item $pwd).parent.parent.name)) { | |
| $Path = '..\' + (Get-Item $pwd).parent.name + '\' + (Split-Path $pwd -Leaf) | |
| } else { | |
| $Path = $pwd.path | |
| } | |
| if($Script:IsAdmin) { | |
| Write-Host " $([char]0xE0A2)" -ForegroundColor Black -BackgroundColor Green -NoNewline | |
| Write-Host "$([char]0xE0B0) " -ForegroundColor Green -BackgroundColor Blue -NoNewline | |
| } | |
| Write-Host $MyInvocation.HistoryId -ForegroundColor Black -BackgroundColor Blue -NoNewline | |
| Write-Host "$([char]0xE0B0) " -ForegroundColor Blue -BackgroundColor Cyan -NoNewline | |
| Write-Host ($path).ToLower().TrimEnd('\') -ForegroundColor White -BackgroundColor Cyan -NoNewline | |
| if ((Write-VcsStatus *>&1).Length -gt 0) { | |
| Write-Host "$([char]0xE0B0)" -ForegroundColor Cyan -BackgroundColor DarkBlue -NoNewline | |
| Write-Host (Write-VcsStatus) -NoNewline -BackgroundColor DarkBlue | |
| Write-Host "$([char]0xE0B0)$("$([char]0xE0B1)" * $NestedPromptLevel)" -ForegroundColor DarkBlue -NoNewline | |
| } else { | |
| Write-Host "$([char]0xE0B0)$("$([char]0xE0B1)" * $NestedPromptLevel)" -ForegroundColor Cyan -NoNewline | |
| } | |
| ' ' | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment