PowerShell_Scripts/base/profile.d/Style.ps1

54 lines
2.2 KiB
PowerShell

$global:IsOutputANSICompatible = (
$PSVersionTable.Platform -eq "Unix"
) -or (
([int]((Get-CimInstance -ClassName Win32_OperatingSystem).Version -split '\.')[0]) -ge 10
) -or (
($env:ConEmuANSI -eq 'ON') -and ($Host.Name -eq 'ConsoleHost' )
)
Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
# Initialize posh-git
Get-Command -ListImported Get-GitDirectory -ErrorAction Ignore |
ForEach-Object {
$null = Get-GitDirectory
if( Test-Path variable:global:GitPromptSettings ) {
$local:g = $global:GitPromptSettings
$g.WorkingColor.ForegroundColor = [System.ConsoleColor]::DarkYellow
$g.TruncatedBranchSuffix = [char]0x2026
$g.PathStatusSeparator = [PoshCode.Pansies.Entities]::ExtendedCharacters.Branch
$g.BeforeStatus.Text = [string]::Empty
$g.AfterStatus.Text = [string]::Empty
$g.BranchGoneStatusSymbol.Text = [char]0x2262
$g.LocalWorkingStatusSymbol.Text = [char]0xF044
$g.LocalStagedStatusSymbol.Text = [char]0xF046
$g.BeforeStash.Text = " $([char]0xF692)"
$g.AfterStash.Text = [string]::Empty
$g.EnableStashStatus = $true
$global:GitPromptSettings = $g
Remove-Variable g
}
}
if( (Get-Command -ListImported Set-PowerLinePrompt -ErrorAction Ignore) ) {
$global:PromptCache = [ordered]@{
OSName = [SystemName]::_GetValidValues("",$true,$true) | Select-Object -First 1
Username = @($env:USER, $env:USERNAME -ne "")[0]
Hostname = $(hostname).Trim()
}
Set-PowerLinePrompt
} elseif( (Get-Command -ListImported Set-PoshPrompt -ErrorAction Ignore) -and $IsOutputANSICompatible ) {
$local:poshPrompt = Join-Path $HOME ".oh-my-posh.omp.json"
if( -not (Test-Path $poshPrompt) ) { $poshPrompt = "slim" }
Set-PoshPrompt -Theme $poshPrompt
} elseif( Get-Command -ListImported Set-Theme -ErrorAction SilentlyContinue ) {
Set-Theme Paradox
} elseif( Get-Module -ListAvailable posh-git -ErrorAction SilentlyContinue ) {
Import-Module posh-git
$GitPromptSettings.AnsiConsole = $IsOutputANSICompatible
}