Skip to content

Instantly share code, notes, and snippets.

@cinnamon-msft
Last active April 2, 2021 17:34
Show Gist options
  • Save cinnamon-msft/5aac1122b3dd3526b6ef469c4a029086 to your computer and use it in GitHub Desktop.
Save cinnamon-msft/5aac1122b3dd3526b6ef469c4a029086 to your computer and use it in GitHub Desktop.
Oh-My-Posh Cinnamon Theme
#requires -Version 2 -Modules posh-git
# local settings
$sl = $global:ThemeSettings
# current folder
$sl.Colors.DriveForegroundColor = [ConsoleColor]::White
$sl.Colors.DriveBackgroundColor = [ConsoleColor]::DarkBlue
# 🏡
$sl.PromptSymbols.HomeSymbol = [char]::ConvertFromUtf32(0x1F3E1)
# 🌟
$sl.PromptSymbols.TerminalSymbol = [char]::ConvertFromUtf32(0x1F31F)
# git status
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
# 👑
$sl.PromptSymbols.ElevatedSymbol = [char]::ConvertFromUtf32(0x1F451)
# 👉
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x1F449)
function Write-Theme
{
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# current folder
$curr_path = Join-Path $pwd ""
$drive = "$(Split-Path -path $curr_path -Leaf)"
if ($curr_path -eq (Join-Path $HOME ""))
{
$drive = $sl.PromptSymbols.HomeSymbol
}
elseif ($drive -eq "terminal") {
$drive = $sl.PromptSymbols.TerminalSymbol
}
$fg_color = $sl.Colors.DriveForegroundColor
$bg_color = $sl.Colors.DriveBackgroundColor
$prompt += Write-Prompt -Object " $drive " -ForegroundColor $fg_color -BackgroundColor $bg_color
# git status
$status = Get-VCSStatus
if ($status)
{
$themeInfo = Get-VcsInfo -status ($status)
$prev_bg_color = $bg_color
$fg_color = $sl.Colors.GitForegroundColor
$bg_color = $themeInfo.BackgroundColor
# transition
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $prev_bg_color -BackgroundColor $bg_color
# segment
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -ForegroundColor $fg_color -BackgroundColor $bg_color
}
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $bg_color
# Next line
$prompt += Set-Newline
# Elevated?
if (Test-Administrator)
{
$prompt += Write-Prompt -Object $sl.PromptSymbols.ElevatedSymbol
}
# Prompt
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator)
$prompt += ' '
$prompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment