Last active
March 29, 2020 16:48
-
-
Save mslot/863f067ea0fe9eeb587eb9e4193b5898 to your computer and use it in GitHub Desktop.
My PowerShell profile and a honukai clone, free to use
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 | |
#original located here: https://github.com/JanDeDobbeleer/oh-my-posh/blob/master/Themes/Honukai.psm1 | |
function Write-Theme { | |
param( | |
[bool] | |
$lastCommandFailed, | |
[string] | |
$with | |
) | |
# write # and space | |
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptHighlightColor | |
# write user | |
$user = [System.Environment]::UserName | |
if (Test-NotDefaultUser($user)) { | |
$prompt += Write-Prompt -Object " $user" -ForegroundColor $sl.Colors.PromptHighlightColor | |
# write at (devicename) | |
$device = Get-ComputerName | |
$prompt += Write-Prompt -Object " at" -ForegroundColor $sl.Colors.PromptForegroundColor | |
$prompt += Write-Prompt -Object " $device" -ForegroundColor $sl.Colors.GitDefaultColor | |
# write in for folder | |
$prompt += Write-Prompt -Object " in" -ForegroundColor $sl.Colors.PromptForegroundColor | |
} | |
# write folder | |
$dir = Get-FullPath -dir $pwd | |
$prompt += Write-Prompt -Object " $dir " -ForegroundColor $sl.Colors.AdminIconForegroundColor | |
# write on (git:branchname status) | |
$status = Get-VCSStatus | |
if ($status) { | |
$sl.GitSymbols.BranchSymbol = '' | |
$themeInfo = Get-VcsInfo -status ($status) | |
$prompt += Write-Prompt -Object 'on git:' -ForegroundColor $sl.Colors.PromptForegroundColor | |
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $themeInfo.BackgroundColor | |
} | |
# write virtualenv | |
if (Test-VirtualEnv) { | |
$prompt += Write-Prompt -Object 'inside env:' -ForegroundColor $sl.Colors.PromptForegroundColor | |
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $themeInfo.VirtualEnvForegroundColor | |
} | |
# 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 | |
$foregroundColor = $sl.Colors.PromptHighlightColor | |
If ($lastCommandFailed) { | |
$foregroundColor = $sl.Colors.CommandFailedIconForegroundColor | |
} | |
if ($with) { | |
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor | |
} | |
$prompt += Set-Newline | |
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $foregroundColor | |
$prompt += ' ' | |
$prompt | |
} | |
function Get-TimeSinceLastCommit { | |
return (git log --pretty=format:'%cr' -1) | |
} | |
$sl = $global:ThemeSettings #local settings | |
$sl.PromptSymbols.StartSymbol = '#' | |
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x279C) | |
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Red | |
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White | |
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Red | |
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed | |
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta | |
$sl.Colors.VirtualEnvForegroundColor = [ConsoleColor]::Red |
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
Import-Module posh-git | |
Import-Module oh-my-posh | |
Set-Theme honukai-clone | |
Set-PSReadLineOption -Colors @{Parameter = "Red"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment