diff options
Diffstat (limited to 'install-win.ps1')
| -rw-r--r-- | install-win.ps1 | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/install-win.ps1 b/install-win.ps1 index bc73e61..aa77243 100644 --- a/install-win.ps1 +++ b/install-win.ps1 | |||
| @@ -1,113 +1,113 @@ | |||
| 1 | #Requires -Version 5.1 | 1 | #Requires -Version 5.1 |
| 2 | <# | 2 | <# |
| 3 | Windows-natives Pendant zu install.sh - kopiert (statt zu verlinken) die | 3 | Windows-natives Pendant zu install.sh - kopiert (statt zu verlinken) die |
| 4 | relevanten Konfigurationen an ihre nativen Windows-Zielorte. Keine | 4 | relevanten Konfigurationen an ihre nativen Windows-Zielorte. Keine |
| 5 | Admin-Rechte noetig (keine Symlinks). | 5 | Admin-Rechte noetig (keine Symlinks). |
| 6 | 6 | ||
| 7 | Aufruf: | 7 | Aufruf: |
| 8 | .\install-win.ps1 | 8 | .\install-win.ps1 |
| 9 | #> | 9 | #> |
| 10 | 10 | ||
| 11 | $ErrorActionPreference = "Stop" | 11 | $ErrorActionPreference = "Stop" |
| 12 | 12 | ||
| 13 | function Write-Ok($msg) { | 13 | function Write-Ok($msg) { |
| 14 | Write-Host "OK $msg" -ForegroundColor Green | 14 | Write-Host "OK $msg" -ForegroundColor Green |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | function Write-Step($msg) { | 17 | function Write-Step($msg) { |
| 18 | Write-Host "==> $msg" -ForegroundColor Cyan | 18 | Write-Host "==> $msg" -ForegroundColor Cyan |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | function Write-SkipMsg($msg) { | 21 | function Write-SkipMsg($msg) { |
| 22 | Write-Host "- $msg" -ForegroundColor DarkGray | 22 | Write-Host "- $msg" -ForegroundColor DarkGray |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | $RepoRoot = $PSScriptRoot | 25 | $RepoRoot = $PSScriptRoot |
| 26 | 26 | ||
| 27 | $NvimSrc = Join-Path $RepoRoot "nvim" | 27 | $NvimSrc = Join-Path $RepoRoot "nvim" |
| 28 | $NvimDst = Join-Path $env:LOCALAPPDATA "nvim" | 28 | $NvimDst = Join-Path $env:LOCALAPPDATA "nvim" |
| 29 | 29 | ||
| 30 | $GitConfigSrc = Join-Path $RepoRoot "git\config" | 30 | $GitConfigSrc = Join-Path $RepoRoot "git\config" |
| 31 | $GitConfigDst = Join-Path $env:USERPROFILE ".gitconfig" | 31 | $GitConfigDst = Join-Path $env:USERPROFILE ".gitconfig" |
| 32 | 32 | ||
| 33 | $GitUp2partsSrc = Join-Path $RepoRoot "git\config-up2parts" | 33 | $GitUp2partsSrc = Join-Path $RepoRoot "git\config-up2parts" |
| 34 | $GitXdgDir = Join-Path $env:USERPROFILE ".config\git" | 34 | $GitXdgDir = Join-Path $env:USERPROFILE ".config\git" |
| 35 | $GitUp2partsDst = Join-Path $GitXdgDir "config-up2parts" | 35 | $GitUp2partsDst = Join-Path $GitXdgDir "config-up2parts" |
| 36 | 36 | ||
| 37 | $NpmrcSrc = Join-Path $RepoRoot "npm\npmrc" | 37 | $NpmrcSrc = Join-Path $RepoRoot "npm\npmrc" |
| 38 | $NpmrcDst = Join-Path $env:USERPROFILE ".npmrc" | 38 | $NpmrcDst = Join-Path $env:USERPROFILE ".npmrc" |
| 39 | 39 | ||
| 40 | function Copy-NvimConfig { | 40 | function Copy-NvimConfig { |
| 41 | Write-Step "nvim -> $NvimDst" | 41 | Write-Step "nvim -> $NvimDst" |
| 42 | 42 | ||
| 43 | if (Test-Path $NvimDst) { | 43 | if (Test-Path $NvimDst) { |
| 44 | Remove-Item -Recurse -Force $NvimDst | 44 | Remove-Item -Recurse -Force $NvimDst |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | Copy-Item -Recurse -Force $NvimSrc $NvimDst | 47 | Copy-Item -Recurse -Force $NvimSrc $NvimDst |
| 48 | Write-Ok $NvimDst | 48 | Write-Ok $NvimDst |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | function Copy-GitConfig { | 51 | function Copy-GitConfig { |
| 52 | Write-Step "git\config -> $GitConfigDst" | 52 | Write-Step "git\config -> $GitConfigDst" |
| 53 | Copy-Item -Force $GitConfigSrc $GitConfigDst | 53 | Copy-Item -Force $GitConfigSrc $GitConfigDst |
| 54 | Write-Ok $GitConfigDst | 54 | Write-Ok $GitConfigDst |
| 55 | 55 | ||
| 56 | if (-not (Test-Path $GitXdgDir)) { | 56 | if (-not (Test-Path $GitXdgDir)) { |
| 57 | New-Item -ItemType Directory -Path $GitXdgDir -Force | Out-Null | 57 | New-Item -ItemType Directory -Path $GitXdgDir -Force | Out-Null |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | Write-Step "git\config-up2parts -> $GitUp2partsDst" | 60 | Write-Step "git\config-up2parts -> $GitUp2partsDst" |
| 61 | Copy-Item -Force $GitUp2partsSrc $GitUp2partsDst | 61 | Copy-Item -Force $GitUp2partsSrc $GitUp2partsDst |
| 62 | Write-Ok "$GitUp2partsDst (wird per includeIf aus .gitconfig eingebunden)" | 62 | Write-Ok "$GitUp2partsDst (wird per includeIf aus .gitconfig eingebunden)" |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | function Copy-Npmrc { | 65 | function Copy-Npmrc { |
| 66 | if (Test-Path $NpmrcDst) { | 66 | if (Test-Path $NpmrcDst) { |
| 67 | Write-SkipMsg "$NpmrcDst existiert bereits, uebersprungen" | 67 | Write-SkipMsg "$NpmrcDst existiert bereits, uebersprungen" |
| 68 | return | 68 | return |
| 69 | } | 69 | } |
| 70 | 70 | ||
| 71 | # HOME ist unter Windows i.d.R. nicht gesetzt, ${HOME} in npm/npmrc wuerde | 71 | # HOME ist unter Windows i.d.R. nicht gesetzt, ${HOME} in npm/npmrc wuerde |
| 72 | # nicht expandieren - Zeile daher auskommentieren statt zweite npmrc-Datei | 72 | # nicht expandieren - Zeile daher auskommentieren statt zweite npmrc-Datei |
| 73 | # zu pflegen. | 73 | # zu pflegen. |
| 74 | Write-Step "npm\npmrc -> $NpmrcDst (prefix-Zeile auskommentiert)" | 74 | Write-Step "npm\npmrc -> $NpmrcDst (prefix-Zeile auskommentiert)" |
| 75 | $lines = Get-Content -Path $NpmrcSrc | ForEach-Object { | 75 | $lines = Get-Content -Path $NpmrcSrc | ForEach-Object { |
| 76 | if ($_ -match "^\s*prefix\s*=") { | 76 | if ($_ -match "^\s*prefix\s*=") { |
| 77 | "; $_ (unter Windows auskommentiert)" | 77 | "; $_ (unter Windows auskommentiert)" |
| 78 | } else { | 78 | } else { |
| 79 | $_ | 79 | $_ |
| 80 | } | 80 | } |
| 81 | } | 81 | } |
| 82 | Set-Content -Path $NpmrcDst -Value $lines | 82 | Set-Content -Path $NpmrcDst -Value $lines |
| 83 | Write-Ok $NpmrcDst | 83 | Write-Ok $NpmrcDst |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | function Add-BinToUserPath { | 86 | function Add-BinToUserPath { |
| 87 | $binDir = Join-Path $RepoRoot "windows\bin" | 87 | $binDir = Join-Path $RepoRoot "windows\bin" |
| 88 | $userPath = [Environment]::GetEnvironmentVariable("PATH", "User") | 88 | $userPath = [Environment]::GetEnvironmentVariable("PATH", "User") |
| 89 | $entries = $userPath -split ";" | 89 | $entries = $userPath -split ";" |
| 90 | 90 | ||
| 91 | if ($entries -contains $binDir) { | 91 | if ($entries -contains $binDir) { |
| 92 | Write-SkipMsg "$binDir bereits im User-PATH" | 92 | Write-SkipMsg "$binDir bereits im User-PATH" |
| 93 | return | 93 | return |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | Write-Step "$binDir zum User-PATH hinzufuegen (enthaelt gmake.cmd)" | 96 | Write-Step "$binDir zum User-PATH hinzufuegen (enthaelt gmake.cmd)" |
| 97 | [Environment]::SetEnvironmentVariable("PATH", "$userPath;$binDir", "User") | 97 | [Environment]::SetEnvironmentVariable("PATH", "$userPath;$binDir", "User") |
| 98 | Write-Ok "$binDir (wirkt erst in neuen Terminal-Sitzungen)" | 98 | Write-Ok "$binDir (wirkt erst in neuen Terminal-Sitzungen)" |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | function Main { | 101 | function Main { |
| 102 | Copy-NvimConfig | 102 | Copy-NvimConfig |
| 103 | Copy-GitConfig | 103 | Copy-GitConfig |
| 104 | Copy-Npmrc | 104 | Copy-Npmrc |
| 105 | Add-BinToUserPath | 105 | Add-BinToUserPath |
| 106 | 106 | ||
| 107 | Write-Host "" | 107 | Write-Host "" |
| 108 | Write-Host "Fertig. Dateien wurden KOPIERT, nicht verlinkt." -ForegroundColor Green | 108 | Write-Host "Fertig. Dateien wurden KOPIERT, nicht verlinkt." -ForegroundColor Green |
| 109 | Write-Host "Nach Aenderungen im Repo dieses Skript erneut ausfuehren." | 109 | Write-Host "Nach Aenderungen im Repo dieses Skript erneut ausfuehren." |
| 110 | Write-Host "Neues Terminal oeffnen, damit PATH-Aenderungen wirksam werden." -ForegroundColor Yellow | 110 | Write-Host "Neues Terminal oeffnen, damit PATH-Aenderungen wirksam werden." -ForegroundColor Yellow |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | Main | 113 | Main |
