Last active
April 20, 2022 03:05
-
-
Save NickCraver/d74c2cd9c5585e52607f659f8903941e to your computer and use it in GitHub Desktop.
My PowerShell PoshGit theme (used with Cmder)
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 | |
# This is a tweaked version of https://github.com/JanJoris/oh-my-posh/blob/master/Themes/Paradox.psm1 | |
function Write-Theme { | |
param( | |
[bool] | |
$lastCommandFailed, | |
[string] | |
$with | |
) | |
$host.UI.RawUI.WindowTitle = Microsoft.PowerShell.Management\Split-Path $pwd.ProviderPath -Leaf | |
#$lastColor = $sl.Colors.PromptBackgroundColor | |
#Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor | |
#check the last command state and indicate if failed | |
If ($lastCommandFailed) { | |
Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor | |
} | |
#check for elevated prompt | |
#If (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) { | |
# Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor | |
#} | |
#$user = [Environment]::UserName | |
#$computer = $env:computername | |
$path = Get-FullPath -dir $pwd | |
#Write-Prompt -Object "$user@$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor | |
if (Test-VirtualEnv) { | |
Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor | |
Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor | |
Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor | |
} | |
else { | |
Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor | |
} | |
# Writes the drive portion | |
Write-Prompt -Object "$path " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor | |
$status = Get-VCSStatus | |
if ($status) { | |
$themeInfo = Get-VcsInfo -status ($status) | |
$lastColor = $themeInfo.BackgroundColor | |
Write-Prompt -Object $($sl.PromptSymbols.SegmentForwardSymbol) -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor | |
Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor | |
} | |
# Writes the postfix to the prompt | |
Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor | |
if ($with) { | |
Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor | |
} | |
Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptBackgroundColor | |
} | |
$sl = $global:ThemeSettings #local settings | |
$sl.PromptSymbols.StartSymbol = ' ' | |
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F) | |
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0) | |
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White | |
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White | |
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue | |
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black | |
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed | |
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta | |
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red | |
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White |
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
# Using https://github.com/dahlbyk/posh-git | |
Import-Module 'C:\tools\poshgit\dahlbyk-posh-git-a4faccd\src\posh-git.psd1' | |
Set-Theme Craver-Paradox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment