#Requires -Version 5.1 <# Installiert Git und delta (Pager fuer git/config) per winget. Aufruf (keine Admin-Rechte noetig): .\bootstrap-win\git.ps1 #> $ErrorActionPreference = "Stop" $script:Failures = @() function Write-Ok($msg) { Write-Host "OK $msg" -ForegroundColor Green } function Write-Step($msg) { Write-Host "==> $msg" -ForegroundColor Cyan } function Write-Skip($msg) { Write-Host "- $msg bereits vorhanden" -ForegroundColor DarkGray } function Write-Warn($msg) { Write-Host "! $msg" -ForegroundColor Yellow $script:Failures += $msg } function Test-CommandExists([string]$Name) { return [bool](Get-Command $Name -ErrorAction SilentlyContinue) } function Install-WingetPackage([string]$Binary, [string]$Id) { if (Test-CommandExists $Binary) { Write-Skip $Binary return } Write-Step "winget install $Id" $output = winget install --id $Id -e --source winget --accept-package-agreements --accept-source-agreements --silent 2>&1 if ($LASTEXITCODE -ne 0) { $lastLine = ($output | Select-Object -Last 3) -join " / " Write-Warn "winget install $Id fehlgeschlagen (Binary '$Binary' nicht gefunden): $lastLine -- Pruefen mit: winget search $Id" return } Write-Ok $Id } function Test-Prerequisites { if (-not (Test-CommandExists "winget")) { Write-Host "Fehler: winget wurde nicht gefunden. 'App Installer' aus dem Microsoft Store installieren." -ForegroundColor Red exit 1 } } function Main { Test-Prerequisites Install-WingetPackage -Binary "git" -Id "Git.Git" Install-WingetPackage -Binary "delta" -Id "dandavison.delta" Write-Host "" if ($script:Failures.Count -eq 0) { Write-Host "Bootstrap abgeschlossen." -ForegroundColor Green } else { Write-Host "Bootstrap abgeschlossen, mit $($script:Failures.Count) Warnung(en):" -ForegroundColor Yellow foreach ($f in $script:Failures) { Write-Host " - $f" -ForegroundColor Yellow } } } Main