-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_windows.ps1
More file actions
249 lines (216 loc) · 7.94 KB
/
install_windows.ps1
File metadata and controls
249 lines (216 loc) · 7.94 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# Function to install Scoop package manager
function Install-Scoop {
Write-Host "Setting up Scoop package manager..."
if (Get-Command scoop -ErrorAction SilentlyContinue) {
Write-Host "Scoop is already installed, updating..."
scoop update --all
}
else {
Write-Host "Installing Scoop..."
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Invoke-RestMethod get.scoop.sh | Invoke-Expression
scoop bucket add java
scoop install sudo
}
}
# Function to install applications via Winget
function Install-Applications {
Write-Host "Installing applications via Winget..."
# Core applications to install
$generalApps = @(
"AgileBits.1Password",
"Google.Chrome",
"Google.Drive",
"TheBrowserCompany.Arc"
)
# Development tools
$devTools = @(
"CoreyButler.NVMforWindows",
"Git.Git",
"GitHub.cli",
"Microsoft.Powershell",
"Microsoft.VisualStudio.2022.BuildTools",
"Microsoft.VisualStudioCode",
"EclipseAdoptium.Temurin.25.JDK",
"Python.Python.3.14",
"Rustlang.Rustup",
"Starship.Starship"
)
# Gaming applications
$gamingApps = @(
"Discord.Discord",
"EpicGames.EpicGamesLauncher",
"Logitech.GHUB",
"Nvidia.GeForceExperience",
"Ubisoft.Connect",
"Valve.Steam"
)
# Combine all applications
$allApps = $generalApps + $devTools + $gamingApps
# Applications that Cannot Be Updated via Winget
$dontUpdate = @(
"Discord.Discord",
"Rustlang.Rustup"
)
# Applications that Require Execution on Install
$executeOnInstall = @(
"Microsoft.VisualStudio.2022.BuildTools",
"Rustlang.Rustup"
)
# Install each application
foreach ($app in $allApps) {
Install-WingetApp -AppId $app -DontUpdate $dontUpdate -ExecuteOnInstall $executeOnInstall
}
}
# Function to install a single Winget application
function Install-WingetApp {
param(
[string]$AppId,
[array]$DontUpdate,
[array]$ExecuteOnInstall
)
if (winget list --id $AppId 2>$null) {
if (-Not $DontUpdate.Contains($AppId)) {
Write-Host "$AppId is already installed, upgrading..."
winget upgrade -h --id $AppId --silent --accept-package-agreements --accept-source-agreements
}
else {
Write-Host "$AppId is already installed (skipping update)."
}
}
elseif ($ExecuteOnInstall.Contains($AppId)) {
Write-Host "Installing (with special execution): $AppId"
winget install -e -h --id $AppId --silent --accept-package-agreements --accept-source-agreements
}
else {
Write-Host "Installing: $AppId"
winget install -h --id $AppId --silent --accept-package-agreements --accept-source-agreements
}
}
# Function to install Python package manager (uv)
function Install-UV {
Write-Host "Installing uv (Python package manager)..."
if (-Not (Get-Command uv -ErrorAction SilentlyContinue)) {
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
}
else {
Write-Host "uv is already installed."
}
}
# Function to install Nerd Fonts
function Install-NerdFonts {
Write-Host "Installing Nerd Fonts via Scoop..."
if (-Not (Get-Command scoop -ErrorAction SilentlyContinue)) {
Write-Host "❌ Scoop not found. Cannot install Nerd Fonts."
return
}
try {
# Add nerd-fonts bucket (only if not already added)
$buckets = scoop bucket list
if ($buckets -notcontains "nerd-fonts") {
Write-Host "Adding nerd-fonts bucket to Scoop..."
scoop bucket add nerd-fonts
} else {
Write-Host "Nerd-fonts bucket already exists."
}
# Check if FiraCode-NF is already installed
$installed = scoop list FiraCode-NF 2>$null
if ($installed) {
Write-Host "FiraCode Nerd Font is already installed, checking for updates..."
scoop update FiraCode-NF
Write-Host "✅ FiraCode Nerd Font updated successfully!"
} else {
Write-Host "Installing FiraCode Nerd Font..."
scoop install FiraCode-NF
Write-Host "✅ FiraCode Nerd Font installed successfully via Scoop!"
}
} catch {
Write-Host "❌ Scoop installation failed. Please install FiraCode Nerd Font manually from: https://github.com/ryanoasis/nerd-fonts/releases"
}
}
# Function to refresh environment PATH
function Update-EnvironmentPath {
Write-Host "Refreshing environment PATH..."
# Add VSCode to PATH if not already present
$vscodePath = "${env:LOCALAPPDATA}\Programs\Microsoft VS Code\bin"
$currentPath = [System.Environment]::GetEnvironmentVariable("Path", "User")
if ((Test-Path $vscodePath) -and ($currentPath -notlike "*$vscodePath*")) {
Write-Host "Adding VSCode to PATH..."
$newPath = $currentPath + ";" + $vscodePath
[System.Environment]::SetEnvironmentVariable("Path", $newPath, "User")
}
# Refresh current session PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + `
[System.Environment]::GetEnvironmentVariable("Path", "User")
}
# Function to Create Symlinks
function Add-Symlink {
param(
[string]$Path,
[string]$Target
)
if (-Not (Test-Path -Path $Path) -And (Test-Path -Path $Target)) {
Write-Host "Creating symlink: $Path -> $Target"
sudo New-Item -ItemType SymbolicLink -Path $Path -Value $Target -Force
}
elseif (Test-Path -Path $Path) {
Write-Host "Symlink already exists: $Path"
}
else {
Write-Host "Target does not exist: $Target"
}
}
# Function to setup PowerShell profiles
function Setup-PowerShellProfiles {
Write-Host "Setting up PowerShell profiles..."
$profileSource = (Get-Item ".\config\powershell\Microsoft.PowerShell_profile.ps1").FullName
# Windows PowerShell (5.1)
$windowsPSDir = "$HOME\Documents\WindowsPowerShell"
mkdir $windowsPSDir -Force | Out-Null
Add-Symlink -Path "$windowsPSDir\Microsoft.PowerShell_profile.ps1" -Target $profileSource
Add-Symlink -Path "$windowsPSDir\Microsoft.VSCode_profile.ps1" -Target $profileSource
# PowerShell Core (7+)
$corePSDir = "$HOME\Documents\PowerShell"
mkdir $corePSDir -Force | Out-Null
Add-Symlink -Path "$corePSDir\Microsoft.PowerShell_profile.ps1" -Target $profileSource
Add-Symlink -Path "$corePSDir\Microsoft.VSCode_profile.ps1" -Target $profileSource
}
# Function to install Node.js via NVM
function Install-Node {
Write-Host "Installing and configuring Node.js..."
# Install and Use Latest LTS Node.js
if (Get-Command nvm -ErrorAction SilentlyContinue) {
sudo nvm install lts
nvm use lts
}
else {
Write-Host "NVM not found. Install CoreyButler.NVMforWindows first."
}
}
# Function to setup dotfiles configuration
function Setup-Dotfiles {
Write-Host "Running dotfiles configuration..."
uv run src/main.py
}
# Function to load PowerShell profile
function Load-PowerShellProfile {
Write-Host "Loading PowerShell profile..."
if (Test-Path $PROFILE) {
. $PROFILE
}
}
# Main installation function
function Start-WindowsInstall {
Install-Scoop
Install-Applications
Install-UV
Install-Node
Install-NerdFonts
Update-EnvironmentPath
Setup-PowerShellProfiles
Setup-Dotfiles
Load-PowerShellProfile
Write-Host "Windows dotfiles installation completed! Please restart your terminal."
}
# Run the main installation
Start-WindowsInstall