From 479338bbcb2dc00b4ba27933e6ec0e6ec48079f7 Mon Sep 17 00:00:00 2001 From: Anthony Perkins Date: Fri, 26 Apr 2024 10:19:50 +0100 Subject: [PATCH] Speed up PowerShell profile --- .../files/Microsoft.PowerShell_profile.ps1 | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/roles/home-cli/files/Microsoft.PowerShell_profile.ps1 b/roles/home-cli/files/Microsoft.PowerShell_profile.ps1 index 0390a89..e0e65ea 100644 --- a/roles/home-cli/files/Microsoft.PowerShell_profile.ps1 +++ b/roles/home-cli/files/Microsoft.PowerShell_profile.ps1 @@ -72,12 +72,6 @@ if ($IsWindows -or ($env:OS -eq "Windows_NT")) { $env:__COMPAT_LAYER = "RunAsInvoker" } -if (!(Get-Command Get-Uptime -ErrorAction SilentlyContinue)) { - function Get-Uptime { - Get-WmiObject Win32_OperatingSystem | Select-Object @{LABEL='LastBootUpTime';EXPRESSION={$_.ConvertToDateTime($_.LastBootUpTime)}} - } -} - if ($nvim = Get-Command nvim.exe -ErrorAction SilentlyContinue) { Set-Alias -Name vi -Value $nvim.Source } @@ -86,16 +80,6 @@ Remove-Variable -Name nvim # Force UTF-8 output. $OutputEncoding = [System.Text.Encoding]::UTF8 -# Try upgrading the default version of PSReadLine to something newer. -if ($null -ne (Get-Module PSReadline).Version -and (Get-Module PSReadline).Version -le [Version]"2.0.0.0") { - try { - Write-Host "PSReadLine <= 2.0.0.0. Trying to upgrade..." - Install-Module -Scope CurrentUser -Name PSReadLine -Force -ErrorAction SilentlyContinue - Write-Host "PSReadLine upgraded. Restart PowerShell to load it." - } catch { - Write-Host "Failed upgrading PSReadline." - } -} Set-PSReadlineOption -BellStyle None Set-PSReadlineOption -EditMode Emacs Set-PSReadlineKeyHandler -Key Tab -Function Complete @@ -114,7 +98,6 @@ Set-PSReadLineKeyHandler -Chord Ctrl+Delete -Function KillWord Set-PSReadLineKeyHandler -Chord Shift+Spacebar -Function SelfInsert # Keep this at the end. -$LocalProfilePath = Join-Path -Path "$PSScriptRoot" -ChildPath "local.ps1" -if (Test-Path $LocalProfilePath -PathType Leaf) { - . $LocalProfilePath +if (Test-Path "$PSScriptRoot/local.ps1") { + . "$PSScriptRoot/local.ps1" }