From d9aa8fafdb914de94bf0c39f6e64d67212b50901 Mon Sep 17 00:00:00 2001 From: js0ny Date: Fri, 14 Feb 2025 21:19:19 +0000 Subject: [PATCH] fix(pwsh, z): Fix zoxide work with pwsh --- tools/powershell/Navigation.ps1 | 17 ----------------- tools/powershell/Prompt.ps1 | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/powershell/Navigation.ps1 b/tools/powershell/Navigation.ps1 index 463d482..99a55ac 100644 --- a/tools/powershell/Navigation.ps1 +++ b/tools/powershell/Navigation.ps1 @@ -9,20 +9,3 @@ ${function:docs} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Docum ${function:down} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Downloads") } ${function:dt} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "Desktop") } ${function:one} = { Set-Location -Path (Join-Path -Path $HOME -ChildPath "OneDrive") } - - -if (Get-Command zoxide -ErrorAction SilentlyContinue) { - Invoke-Expression (& { (zoxide init powershell | Out-String) }) - ${function:...} = { z -Path (Join-Path -Path .. -ChildPath ..) } - ${function:....} = { z -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) } - ${function:.....} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) } - ${function:......} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) } - ${function:z-} = { z - } -} -else { - ${function:...} = { Set-Location -Path (Join-Path -Path .. -ChildPath ..) } - ${function:....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) } - ${function:.....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) } - ${function:......} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) } - ${function:z-} = { Set-Location - } -} diff --git a/tools/powershell/Prompt.ps1 b/tools/powershell/Prompt.ps1 index 105dacd..ae31068 100644 --- a/tools/powershell/Prompt.ps1 +++ b/tools/powershell/Prompt.ps1 @@ -49,3 +49,22 @@ $Colors = @{ # Set the colours Set-PSReadLineOption -Colors $Colors + +# Smarter cd +# Init zoxide apter starship to avoid conflicts +# https://github.com/ajeetdsouza/zoxide/issues/723 +if (Get-Command zoxide -ErrorAction SilentlyContinue) { + Invoke-Expression (& { (zoxide init powershell | Out-String) }) + ${function:...} = { z -Path (Join-Path -Path .. -ChildPath ..) } + ${function:....} = { z -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) } + ${function:.....} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) } + ${function:......} = { z -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) } + ${function:z-} = { z - } +} +else { + ${function:...} = { Set-Location -Path (Join-Path -Path .. -ChildPath ..) } + ${function:....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) } + ${function:.....} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) } + ${function:......} = { Set-Location -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path (Join-Path -Path .. -ChildPath ..) -ChildPath ..) -ChildPath ..) -ChildPath ..) } + ${function:z-} = { Set-Location - } +}