# ensure-git-bash.ps1 # Ensures that the 'bash' command in the current PowerShell session resolves to # Git for Windows / MSYS bash (required by ClaudeTools .sh scripts, vault, hooks, etc.) # instead of the WSL stub in WindowsApps. # # Usage: # . .claude/scripts/ensure-git-bash.ps1 # Or source in profile. # # Idempotent and safe. $gitBin = "C:\Program Files\Git\bin" $gitUsrBin = "C:\Program Files\Git\usr\bin" if (Test-Path $gitBin) { $current = (Get-Command bash -ErrorAction SilentlyContinue).Source if ($current -notlike '*Git*bin*bash.exe') { # Remove any existing Git entries first to avoid duplicates, then prepend $env:Path = "$gitBin;$gitUsrBin;" + ($env:Path -replace [regex]::Escape("$gitBin;"), '' -replace [regex]::Escape("$gitUsrBin;"), '') Write-Verbose "[ensure-git-bash] Remapped 'bash' to Git/MSYS bash" } } else { Write-Warning "[ensure-git-bash] Git Bash not found at expected path $gitBin" }