Improve performance of Package identification

Using -ListAvailable with Get-Command to ensure no module loading is
    attampeted while querying loaded commands.
    This improved performance when certain modules have not been
    loaded yet
This commit is contained in:
Gal Szkolnik 2021-04-27 16:04:12 +00:00
parent 499a86baa6
commit 22aa3ba435
10 changed files with 17 additions and 17 deletions

View file

@ -3,13 +3,13 @@ $global:IsOutputANSICompatible = (
) -or (
($env:ConEmuANSI -eq 'ON') -and ($Host.Name -eq 'ConsoleHost' )
)
Get-Command Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
Get-Command -ListImported Set-PSReadLineKeyHandler -ErrorAction SilentlyContinue |
ForEach-Object { Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete }
if( (Get-Command Set-PoshPrompt -ErrorAction SilentlyContinue) -and $IsOutputANSICompatible ) {
if( (Get-Command -ListImported Set-PoshPrompt -ErrorAction SilentlyContinue) -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 Set-Theme -ErrorAction SilentlyContinue ) {
} elseif( Get-Command -ListImported Set-Theme -ErrorAction SilentlyContinue ) {
Set-Theme Paradox
} elseif( Get-Module -ListAvailable posh-git -ErrorAction SilentlyContinue ) {
Import-Module posh-git