Improved git prompt styling
This commit is contained in:
parent
532f82775b
commit
3d52285361
|
@ -18,15 +18,15 @@ $local:MyPowerLineSetup = [ordered]@{
|
||||||
Prompt = @(
|
Prompt = @(
|
||||||
{ "`n" } # A spaced line
|
{ "`n" } # A spaced line
|
||||||
{ New-PromptText -EBg VioletRed4 $MyInvocation.HistoryId }
|
{ New-PromptText -EBg VioletRed4 $MyInvocation.HistoryId }
|
||||||
{ Get-Elapsed -Trim }
|
|
||||||
{ Get-SegmentedPath -LengthLimit 30 }
|
{ Get-SegmentedPath -LengthLimit 30 }
|
||||||
{ Write-VcsStatus }
|
{ Write-VcsStatus }
|
||||||
|
|
||||||
# Right-align block
|
# Right-align block
|
||||||
{ "`t" }
|
{ "`t" }
|
||||||
{ "$env:USERNAME @ $env:COMPUTERNAME" }
|
{ "$($PromptCache.Username)@$($PromptCache.Hostname)" }
|
||||||
|
{ Get-Elapsed -Trim }
|
||||||
{ Get-Date -Format 'HH:mm:ss' }
|
{ Get-Date -Format 'HH:mm:ss' }
|
||||||
{ Get-Date -Format 'MM/dd ddd' }
|
{ Get-Date -Format 'ddd(dd)' }
|
||||||
{ "$PSOSName " }
|
{ "$PSOSName " }
|
||||||
|
|
||||||
{ "`n" }
|
{ "`n" }
|
||||||
|
|
|
@ -7,15 +7,38 @@ $global:IsOutputANSICompatible = (
|
||||||
)
|
)
|
||||||
Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
|
Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
|
||||||
ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
|
ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
|
||||||
if( (Get-Command -ListImported Set-PowerLinePrompt -ErrorAction Ignore) ) {
|
|
||||||
$global:PSOSName = [SystemName]::_GetValidValues("",$true,$true) | Select-Object -First 1
|
|
||||||
|
|
||||||
if( Get-Command -ListImported Get-GitDirectory -ErrorAction Ignore ) { $null = Get-GitDirectory }
|
# Initialize posh-git
|
||||||
if( Test-Path variable:global:GitPromptSettings ) {
|
Get-Command -ListImported Get-GitDirectory -ErrorAction Ignore |
|
||||||
$global:GitPromptSettings.TruncatedBranchSuffix = [char]0x2026
|
ForEach-Object {
|
||||||
$global:GitPromptSettings.BeforeStatus.Text = [PoshCode.Pansies.Entities]::ExtendedCharacters.Branch
|
$null = Get-GitDirectory
|
||||||
$global:GitPromptSettings.AfterStatus.Text = [string]::Empty
|
|
||||||
|
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
|
Set-PowerLinePrompt
|
||||||
} elseif( (Get-Command -ListImported Set-PoshPrompt -ErrorAction Ignore) -and $IsOutputANSICompatible ) {
|
} elseif( (Get-Command -ListImported Set-PoshPrompt -ErrorAction Ignore) -and $IsOutputANSICompatible ) {
|
||||||
$local:poshPrompt = Join-Path $HOME ".oh-my-posh.omp.json"
|
$local:poshPrompt = Join-Path $HOME ".oh-my-posh.omp.json"
|
||||||
|
|
Loading…
Reference in New Issue