From 612579bb3403b08fa67631cb006b62c1364373f3 Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Wed, 27 Oct 2021 21:37:29 +0200 Subject: [PATCH] Avoid reinstall package --- install.ps1 | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index d4a4000..69c914e 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,12 +1,19 @@ # Install OhMyPosh -winget install JanDeDobbeleer.OhMyPosh +winget list -q JanDeDobbeleer.OhMyPosh +if ($? -eq $False) { + winget install JanDeDobbeleer.OhMyPosh +} # Reload path $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") # Install modules -Install-Module -Name Terminal-Icons -Repository PSGallery -Force -Install-Module -Name PSReadLine -AllowPrerelease -Force +if (-not (Get-Module -ListAvailable -Name Terminal-Icons)) { + Install-Module -Name Terminal-Icons -Repository PSGallery -Force +} +if (-not (Get-Module -ListAvailable -Name PSReadLine)) { + Install-Module -Name PSReadLine -AllowPrerelease -Force +} # Update profile configuration @@ -29,9 +36,16 @@ if ($host.Name -eq 'ConsoleHost') Write-Output "oh-my-posh --init --shell pwsh --config '$powershellConfig' | Invoke-Expression" | Out-File -FilePath $PROFILE -Append # 2. Configure PSReadLine | Predictive Intellisense -Write-Output 'Set-PSReadLineOption -PredictionSource History' | Out-File -FilePath $PROFILE -Append -Write-Output 'Set-PSReadLineOption -PredictionViewStyle ListView' | Out-File -FilePath $PROFILE -Append -Write-Output 'Set-PSReadLineOption -EditMode Windows' | Out-File -FilePath $PROFILE -Append +Write-Output @' +$PSReadLineOptions = @{ + EditMode = "Windows" + HistoryNoDuplicates = $True + PredictionSource = "History" + CompletionQueryItems = 5 + ShowToolTips = $True +} +Set-PSReadLineOption @PSReadLineOptions +'@ | Out-File -FilePath $PROFILE -Append # Reload profile . $PROFILE \ No newline at end of file