Skip to content

Instantly share code, notes, and snippets.

@hasparus
Last active September 15, 2018 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hasparus/9dcbcb2ffa912c3494c422163bfd1f7c to your computer and use it in GitHub Desktop.
Save hasparus/9dcbcb2ffa912c3494c422163bfd1f7c to your computer and use it in GitHub Desktop.
AvitEmojiStatus -- my powershell theme
# thank you Aaron -- https://www.aaron-powell.com/posts/2018-01-30-the-happy-powershell-prompt/
# and you, Jan -- https://github.com/JanDeDobbeleer/oh-my-posh/blame/master/Themes/Avit.psm1
#requires -Version 2 -Modules posh-git
$happyPrompts = @('πŸ‘»'; 'πŸ€–'; 'πŸ––'; '❀️'; '🌷'; '🐸'; '🍺'; 'πŸ˜€'; '🀜'; 'πŸŽ‰'; '🀟'; 'πŸ‘Œ'; '🌈'; 'πŸ—Ώ'; 'πŸ’―'; 'πŸŒ‹'; '🌌';)
$angryPrompts = @('πŸ‘Ώ'; 'πŸ‘Ή'; '😭'; '🀒'; 'πŸ’€'; 'πŸ‘Ί'; 'πŸ•΅οΈ'; 'πŸ€·β€'; 'πŸ–•'; 'πŸ”₯'; '🌑️'; 'πŸ”ͺ';)
function Write-Random {
param([string[]] $arr)
Write-Prompt -Object " $($arr[(Get-Random -min 0 -max ($arr.Length))]) " -ForegroundColor $sl.Colors.PromptForegroundColor
}
function Write-Theme {
param([bool] $lastCommandFailed, [string] $with)
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor
$dir = Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object $dir -ForegroundColor $sl.Colors.PromptForegroundColor
$status = Get-VCSStatus
if ($status) {
$vcsInfo = Get-VcsInfo -status ($status)
$info = $vcsInfo.VcInfo
$prompt += Write-Prompt -Object " $info" -ForegroundColor $vcsInfo.BackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.ElevatedSymbol)" -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Random $angryPrompts
} Else {
$prompt += Write-Random $happyPrompts
}
$prompt += Set-Newline
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
# $prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += "> "
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.Colors.PromptForegroundColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment