-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
164 lines (139 loc) · 5.42 KB
/
install.ps1
File metadata and controls
164 lines (139 loc) · 5.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Dotfiles bootstrap script for Windows.
# Installs packages via winget (preferred) with choco fallback for fonts.
#Requires -RunAsAdministrator
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
# ── Package lists ─────────────────────────────────────────────────────
# winget packages: Id as used by `winget install`
$WingetPackages = @(
"Git.Git"
"Neovim.Neovim"
"Starship.Starship"
"sharkdp.bat"
"BurntSushi.ripgrep"
"sharkdp.fd"
"dandavison.delta"
"eza-community.eza"
"junegunn.fzf"
"ajeetdsouza.zoxide"
"atuinsh.atuin"
"Schniz.fnm"
"GoLang.Go"
)
# Nerd Fonts — only available via choco
$ChocoFonts = @(
"nerd-fonts-hack"
"nerd-fonts-fira-code"
"nerd-fonts-jetbrains-mono"
"nerd-fonts-iosevka"
)
# ── Helpers ───────────────────────────────────────────────────────────
function Test-Command {
param([string]$Name)
return [bool](Get-Command $Name -ErrorAction SilentlyContinue)
}
function Install-Winget {
if (Test-Command "winget") { return }
Write-Host "winget not found. Please install App Installer from the Microsoft Store."
Write-Host "https://aka.ms/getwinget"
exit 1
}
function Install-Chocolatey {
if (Test-Command "choco") { return }
Write-Host "Installing Chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression (
(New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
)
}
function Install-WingetPackage {
param([string]$Id)
$installed = winget list --id $Id --accept-source-agreements 2>$null
if ($LASTEXITCODE -eq 0 -and $installed -match $Id) {
Write-Host " [OK] $Id already installed"
return
}
Write-Host " Installing $Id..."
winget install --id $Id --accept-package-agreements --accept-source-agreements --silent
}
function Install-ChocoPackage {
param([string]$Name)
$installed = choco list --local-only 2>$null | Select-String -Pattern "^$Name "
if ($installed) {
Write-Host " [OK] $Name already installed"
return
}
Write-Host " Installing $Name..."
choco install $Name -y
}
# ── Main ──────────────────────────────────────────────────────────────
function Install-Packages {
Write-Host "`n=== Installing packages via winget ==="
Install-Winget
foreach ($pkg in $WingetPackages) {
Install-WingetPackage -Id $pkg
}
Write-Host "`n=== Installing Nerd Fonts via Chocolatey ==="
Install-Chocolatey
foreach ($font in $ChocoFonts) {
Install-ChocoPackage -Name $font
}
}
function Set-DefaultEditor {
# Set EDITOR/VISUAL to nvim for git and other tools
$nvimPath = (Get-Command nvim -ErrorAction SilentlyContinue)?.Source
if ($nvimPath) {
[System.Environment]::SetEnvironmentVariable("EDITOR", $nvimPath, "User")
[System.Environment]::SetEnvironmentVariable("VISUAL", $nvimPath, "User")
Write-Host "EDITOR/VISUAL set to $nvimPath"
}
}
function Install-NodeLTS {
# Refresh PATH so fnm is available
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
if (-not (Test-Command "fnm")) {
Write-Host "fnm not found after install — skipping Node setup"
return
}
Write-Host "`n=== Setting up Node.js LTS via fnm ==="
fnm install --lts
fnm default lts-latest
Write-Host "Node: $(fnm exec --using=default node -- --version)"
}
function Install-Pi {
if (Test-Command "pi") {
Write-Host " [OK] pi-coding-agent already installed"
return
}
# Refresh PATH so fnm/node/npm are available
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
if (-not (Test-Command "npm")) {
Write-Host "npm not found — skipping pi install"
return
}
Write-Host "Installing pi-coding-agent..."
npm install -g @mariozechner/pi-coding-agent
}
function Install-Chezmoi {
if (-not (Test-Command "chezmoi")) {
Write-Host "`nInstalling chezmoi..."
winget install --id twpayne.chezmoi --accept-package-agreements --accept-source-agreements --silent
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" +
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
$scriptDir = Split-Path -Parent $MyInvocation.ScriptName
Write-Host "Running 'chezmoi init --apply --source=$scriptDir'"
chezmoi init --apply --source="$scriptDir"
}
# ── Run ───────────────────────────────────────────────────────────────
Install-Packages
Install-NodeLTS
Install-Pi
Set-DefaultEditor
Install-Chezmoi
Write-Host "`nInstallation complete!"