Created
July 8, 2020 07:58
-
-
Save unrooted/b91f8f16f4169aacd853e65800e66de0 to your computer and use it in GitHub Desktop.
My Oh-My-Posh theme
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
#requires -Version 2 -Modules posh-git | |
function Write-Theme { | |
param( | |
[bool] | |
$lastCommandFailed, | |
[string] | |
$with | |
) | |
#check the last command state and indicate if failed | |
If ($lastCommandFailed) { | |
$prompt = Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor | |
} | |
#check for elevated prompt | |
If (Test-Administrator) { | |
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.PromptHighlightColor | |
} | |
$lambda = [char]::ConvertFromUtf32(0x000003BB) | |
$sTime = " $(Get-Date -Format HH:mm)" | |
if (Test-NotDefaultUser($lambda)) { | |
$prompt += Write-Prompt -Object "$lambda $sTime " -ForegroundColor $sl.Colors.PromptForegroundColor | |
} | |
# Writes the drive portion | |
$prompt += Write-Prompt -Object "$(Get-FullPath -dir $pwd) " -ForegroundColor $sl.Colors.PromptHighlightColor | |
$status = Get-VCSStatus | |
if ($status) { | |
$themeInfo = Get-VcsInfo -status ($status) | |
$prompt += Write-Prompt -Object "git:" -ForegroundColor $sl.Colors.PromptForegroundColor | |
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $sl.Colors.PromptHighlightColor | |
} | |
# write virtualenv | |
if (Test-VirtualEnv) { | |
$prompt += Write-Prompt -Object 'env:' -ForegroundColor $sl.Colors.PromptHighlightColor | |
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $themeInfo.VirtualEnvForegroundColor | |
} | |
if ($with) { | |
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor | |
} | |
# Writes the postfixes to the prompt | |
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptSymbolColor | |
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptSymbolColor | |
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptSymbolColor | |
$prompt += ' ' | |
$prompt | |
} | |
$sl = $global:ThemeSettings #local settings | |
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F) | |
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White | |
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White | |
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkRed | |
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed | |
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment