From 532f82775beb76c174d6fea3c2ba9ef52a48d1f3 Mon Sep 17 00:00:00 2001 From: lksz Date: Mon, 11 Oct 2021 21:37:18 -0400 Subject: [PATCH] Cleaner prompt, Reload-MyScripts -Update switch --- base/Reload-MyScripts.ps1 | 11 ++++++++++- base/Setup-MyPowerLineTheme.ps1 | 4 ++-- base/profile.d/Style.ps1 | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/base/Reload-MyScripts.ps1 b/base/Reload-MyScripts.ps1 index f557bf4..bf89c2b 100644 --- a/base/Reload-MyScripts.ps1 +++ b/base/Reload-MyScripts.ps1 @@ -1,4 +1,6 @@ -[CmdletBinding(SupportsShouldProcess)]param() +[CmdletBinding(SupportsShouldProcess)]param( + [switch]$Update +) function RemoveAlias { param([string]$Name) @@ -23,6 +25,13 @@ function SafeSetAlias { } } +if( $Update -and (Get-Command git -ErrorAction Ignore) ) { + Push-Location $MyPSScriptRoot + git pull + if( Get-Command Write-VcsStatus -ErrorAction Ignore ) { Write-Host "`n$(Write-VcsStatus)`n" } + Pop-Location +} + try { Get-Alias Get-MyAliases -ErrorAction Stop | ForEach-Object { . RemoveAlias $($_.Name) } } catch {} function Get-MyAliases { [CmdletBinding()]param([switch]$ScriptsOnly) diff --git a/base/Setup-MyPowerLineTheme.ps1 b/base/Setup-MyPowerLineTheme.ps1 index 5e0d139..ba8bb2e 100644 --- a/base/Setup-MyPowerLineTheme.ps1 +++ b/base/Setup-MyPowerLineTheme.ps1 @@ -20,7 +20,7 @@ $local:MyPowerLineSetup = [ordered]@{ { New-PromptText -EBg VioletRed4 $MyInvocation.HistoryId } { Get-Elapsed -Trim } { Get-SegmentedPath -LengthLimit 30 } - { if( Get-GitStatus ) { "$([PoshCode.Pansies.Entities]::ExtendedCharacters.Branch)$(Write-VcsStatus)" } } + { Write-VcsStatus } # Right-align block { "`t" } @@ -35,4 +35,4 @@ $local:MyPowerLineSetup = [ordered]@{ } Set-PowerLinePrompt @MyPowerLineSetup -Write-Host -ForegroundColor Cyan "PowerLine Theme is ready, if you want to persist it, don't forget to run Export-PowerLinePrompt" +Write-Host -ForegroundColor Cyan "PowerLine Theme is ready, if you want to persist it, don't forget to run Export-PowerLinePrompt`n" diff --git a/base/profile.d/Style.ps1 b/base/profile.d/Style.ps1 index 0110e18..1d44e74 100644 --- a/base/profile.d/Style.ps1 +++ b/base/profile.d/Style.ps1 @@ -10,8 +10,11 @@ Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue 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 } if( Test-Path variable:global:GitPromptSettings ) { $global:GitPromptSettings.TruncatedBranchSuffix = [char]0x2026 + $global:GitPromptSettings.BeforeStatus.Text = [PoshCode.Pansies.Entities]::ExtendedCharacters.Branch + $global:GitPromptSettings.AfterStatus.Text = [string]::Empty } Set-PowerLinePrompt } elseif( (Get-Command -ListImported Set-PoshPrompt -ErrorAction Ignore) -and $IsOutputANSICompatible ) {