Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(powershell): handle multiple binaries with same name (#652)
Maximilian Roos1f55823c3dfb
diff --git a/src/snapshots/worktrunk__shell__tests__init_powershell.snap b/src/snapshots/worktrunk__shell__tests__init_powershell.snapindex 5e7c7b7b3..e5c4ee17e 100644--- a/src/snapshots/worktrunk__shell__tests__init_powershell.snap+++ b/src/snapshots/worktrunk__shell__tests__init_powershell.snap@@ -19,7 +19,8 @@ if (Get-Command wt -ErrorAction SilentlyContinue) {[string[]]$Arguments)- $wtBin = (Get-Command wt -CommandType Application).Source+ # Select-Object -First 1 handles case where multiple binaries match (e.g., wt.exe from Windows Terminal)+ $wtBin = (Get-Command wt -CommandType Application | Select-Object -First 1).Source$directiveFile = [System.IO.Path]::GetTempFileName()try {@@ -67,7 +68,7 @@ if (Get-Command wt -ErrorAction SilentlyContinue) {# This registers Register-ArgumentCompleter with proper handling$env:COMPLETE = "powershell"try {- & (Get-Command wt -CommandType Application) | Out-String | Invoke-Expression+ & (Get-Command wt -CommandType Application | Select-Object -First 1) | Out-String | Invoke-Expression}finally {Remove-Item Env:\COMPLETE -ErrorAction SilentlyContinuediff --git a/templates/powershell.ps1 b/templates/powershell.ps1index 9e874fb1c..68918e23c 100644--- a/templates/powershell.ps1+++ b/templates/powershell.ps1@@ -15,7 +15,8 @@ if (Get-Command {{ cmd }} -ErrorAction SilentlyContinue) {[string[]]$Arguments)- $wtBin = (Get-Command {{ cmd }} -CommandType Application).Source+ # Select-Object -First 1 handles case where multiple binaries match (e.g., wt.exe from Windows Terminal)+ $wtBin = (Get-Command {{ cmd }} -CommandType Application | Select-Object -First 1).Source$directiveFile = [System.IO.Path]::GetTempFileName()try {@@ -63,7 +64,7 @@ if (Get-Command {{ cmd }} -ErrorAction SilentlyContinue) {# This registers Register-ArgumentCompleter with proper handling$env:COMPLETE = "powershell"try {- & (Get-Command {{ cmd }} -CommandType Application) | Out-String | Invoke-Expression+ & (Get-Command {{ cmd }} -CommandType Application | Select-Object -First 1) | Out-String | Invoke-Expression}finally {Remove-Item Env:\COMPLETE -ErrorAction SilentlyContinue