feat: add Git Bash PATH support to installer

- Add Add-ToBashProfile helper to append install dir to ~/.bashrc
- Converts Windows paths to Unix-style for Git Bash compatibility
- Integrate into Main install flow alongside Add-ToUserPath
- Update completion message to mention Git Bash
This commit is contained in:
BB-fat
2026-06-23 11:00:47 +08:00
parent 45c85fa64a
commit ab6aa16dfc
+30 -2
View File
@@ -100,6 +100,31 @@ function Add-ToSessionPath {
$env:PATH = "$Dir;$env:PATH" $env:PATH = "$Dir;$env:PATH"
} }
# ── Git Bash (bash environment) PATH helper ──────────────────────────────────
function Add-ToBashProfile {
param([string]$Dir)
# Convert Windows path (e.g. C:\Users\foo\.local\bin) to Git-Bash Unix-style (/c/Users/foo/.local/bin)
$unixPath = $Dir -replace '\\', '/'
if ($unixPath -match '^([A-Z]):(.*)$') {
$unixPath = '/' + $matches[1].ToLower() + $matches[2]
}
$bashRc = Join-Path $HOME ".bashrc"
$exportLine = "export PATH=""${unixPath}:`$PATH"" # bsk CLI"
if (Test-Path $bashRc) {
$content = Get-Content $bashRc -Raw -ErrorAction SilentlyContinue
if ($content -match [regex]::Escape($unixPath)) {
Write-Log "$unixPath is already in ~/.bashrc"
return
}
}
Add-Content $bashRc "`n$exportLine" -Encoding ASCII
Write-Log "added ${unixPath} to ~/.bashrc"
}
# ── Main ────────────────────────────────────────────────────────────────────── # ── Main ──────────────────────────────────────────────────────────────────────
function Main { function Main {
@@ -145,9 +170,12 @@ function Main {
# Add to session PATH (current shell) # Add to session PATH (current shell)
Add-ToSessionPath $InstallDir Add-ToSessionPath $InstallDir
# Add to user PATH (persistent) # Add to user PATH (persistent, for PowerShell / cmd)
Add-ToUserPath $InstallDir Add-ToUserPath $InstallDir
# Add to Git Bash PATH (persistent, for bash-based shells / agents)
Add-ToBashProfile $InstallDir
# Verify # Verify
$bskPath = Join-Path $InstallDir "bsk.exe" $bskPath = Join-Path $InstallDir "bsk.exe"
if (Get-Command bsk -ErrorAction SilentlyContinue) { if (Get-Command bsk -ErrorAction SilentlyContinue) {
@@ -159,7 +187,7 @@ function Main {
Write-Log "done" Write-Log "done"
Write-Host "" Write-Host ""
Write-Host "Open a new PowerShell window for PATH changes to take full effect." Write-Host "Open a new terminal (PowerShell / Git Bash) for PATH changes to take full effect."
} }
finally { finally {
Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue