Private/Open-WorktreeTerminal.ps1
|
<#
.SYNOPSIS Opens a new terminal window in the given directory. .DESCRIPTION Uses Windows Terminal (wt) when available; falls back to pwsh (PS7), then powershell (PS5) when neither wt nor pwsh is found. #> function Open-WorktreeTerminal { [CmdletBinding()] param( [Parameter(Mandatory)] [string] $WorktreePath ) if (Get-Command wt -ErrorAction SilentlyContinue) { Start-Process wt -ArgumentList "-d `"$WorktreePath`"" } elseif (Get-Command pwsh -ErrorAction SilentlyContinue) { Start-Process pwsh -ArgumentList '-NoExit', '-Command', "Set-Location '$WorktreePath'" } else { Start-Process powershell -ArgumentList '-NoExit', '-Command', "Set-Location '$WorktreePath'" } Write-Host "Terminal opened : $WorktreePath" -ForegroundColor Cyan } |