1
1
# requires -Version 7
2
2
3
- # cSpell:disable
4
-
5
3
function Test-IsElevated {
6
4
return (New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity ]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator)
7
5
}
@@ -10,26 +8,25 @@ function Test-DeveloperMode {
10
8
$RegistryKeyPath = " HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
11
9
if ((Test-Path $RegistryKeyPath ) -and (Get-ItemProperty - Path $RegistryKeyPath | Select-Object - ExpandProperty AllowDevelopmentWithoutDevLicense)) {
12
10
return $true
13
- }
14
- else {
11
+ } else {
15
12
return $false
16
13
}
17
14
}
18
15
19
16
function Set-GsudoCacheMode {
20
17
param ([switch ]$on , [switch ]$off )
21
18
if (Get-Command gsudo - ErrorAction SilentlyContinue) {
22
- if ($on ) {
19
+ if ($on ) {
23
20
# Write-PrettyTitle "Enable Gsudo CacheMode"
24
21
Start-Sleep - Seconds 5
25
- & gsudo cache on
22
+ & gsudo cache on
26
23
}
27
- if ($off ) {
24
+ if ($off ) {
28
25
# Write-PrettyTitle "Disable Gsudo CacheMode"
29
26
Start-Sleep - Seconds 5
30
- & gsudo cache off
27
+ & gsudo cache off
31
28
}
32
- }
29
+ }
33
30
}
34
31
35
32
# ##################################################################################################
@@ -64,8 +61,7 @@ function Write-PrettyOutput {
64
61
Write-Host " $Entry " - ForegroundColor Magenta - NoNewline
65
62
Write-Host " $Entry2 " - ForegroundColor Yellow - NoNewline
66
63
Write-Host " $Message "
67
- }
68
- else {
64
+ } else {
69
65
Write-Host " $Process " - ForegroundColor Green - NoNewline
70
66
Write-Host " ▏ " - ForegroundColor DarkGray - NoNewline
71
67
Write-Host " $Entry " - ForegroundColor Yellow - NoNewline
@@ -95,9 +91,8 @@ function Install-WingetApps {
95
91
$installed = winget list -- exact -- accept- source- agreements - q $app
96
92
if (! [String ]::Join(" " , $installed ).Contains($app )) {
97
93
gum spin -- title= " Installing $app ..." -- winget install -- exact -- silent -- accept- package- agreements -- accept- source- agreements $app - s winget
98
- Write-PrettyOutput - Process " winget" - Entry " $app " - Message " installed sucessfully."
99
- }
100
- else {
94
+ Write-PrettyOutput - Process " winget" - Entry " $app " - Message " installed successfully."
95
+ } else {
101
96
Write-PrettyOutput - Process " winget" - Entry " $app " - Message " already installed! Skipping..."
102
97
}
103
98
}
@@ -110,8 +105,7 @@ function Enable-ScoopBuckets {
110
105
if (! (Test-Path - PathType Container - Path " $scoopBucketDir \$bucket " )) {
111
106
gum spin -- title= " Adding $bucket to Scoop..." -- scoop bucket add $bucket
112
107
Write-PrettyOutput - Process " scoop" - Entry " bucket:" - Entry2 " $bucket " - Message " added for scoop." - Extra
113
- }
114
- else {
108
+ } else {
115
109
Write-PrettyOutput - Process " scoop" - Entry " bucket:" - Entry2 " $bucket " - Message " already added! Skipping..." - Extra
116
110
}
117
111
}
@@ -129,18 +123,15 @@ function Install-ScoopApps {
129
123
if ($Scope -eq ' AllUsers' ) {
130
124
if ($ (gsudo status IsElevated) -eq $False ) {
131
125
gum spin -- title= " Installing $app globally..." -- gsudo scoop install $app -- global
132
- }
133
- else {
126
+ } else {
134
127
gum spin -- title= " Installing $app globally..." -- scoop install $app -- global
135
128
}
136
129
Write-PrettyOutput - Process " scoop" - Entry " app:" - Entry2 " $app " - Message " globally installed successfully." - Extra
137
- }
138
- else {
130
+ } else {
139
131
gum spin -- title= " Installing $app ..." -- scoop install $app
140
132
Write-PrettyOutput - Process " scoop" - Entry " app:" - Entry2 " $app " - Message " installed successfully." - Extra
141
133
}
142
- }
143
- else {
134
+ } else {
144
135
Write-PrettyOutput - Process " scoop" - Entry " app:" - Entry2 " $app " - Message " already installed! Skipping..." - Extra
145
136
}
146
137
}
@@ -153,8 +144,7 @@ function Install-Modules {
153
144
if (! (Get-Module - ListAvailable - Name $module - ErrorAction SilentlyContinue)) {
154
145
Install-Module - Name $module - AllowClobber - Scope CurrentUser - Force
155
146
Write-PrettyOutput - Process " pwsh" - Entry " module:" - Entry2 " $module " - Message " installed successfully." - Extra
156
- }
157
- else {
147
+ } else {
158
148
Write-PrettyOutput - Process " pwsh" - Entry " module:" - Entry2 " $module " - Message " already installed! Skipping..." - Extra
159
149
}
160
150
}
@@ -178,8 +168,7 @@ function Install-VSCode-Extensions {
178
168
if (-not ($installed | Select-String $ext )) {
179
169
gum spin -- title= " Installing extension $ext ..." -- code -- install-extension $ext -- force
180
170
Write-PrettyOutput - Process " vscode" - Entry " extension:" - Entry2 " $ext " - Message " installed successfully." - Extra
181
- }
182
- else {
171
+ } else {
183
172
Write-PrettyOutput - Process " vscode" - Entry " extension:" - Entry2 " $ext " - Message " already installed. Skipping..." - Extra
184
173
}
185
174
}
@@ -196,8 +185,7 @@ function Install-GitHub-Extensions {
196
185
if (-not ($installed | Select-String " $extRepo " )) {
197
186
gum spin -- title= " Installing extension $extName ..." -- gh extension install " $extRepo " -- force
198
187
Write-PrettyOutput - Process " github" - Entry " extension:" - Entry2 " $extName " - Message " installed successfully." - Extra
199
- }
200
- else {
188
+ } else {
201
189
Write-PrettyOutput - Process " github" - Entry " extension:" - Entry2 " $extName " - Message " already installed. Skipping..." - Extra
202
190
}
203
191
}
@@ -214,8 +202,7 @@ function Install-NPM-Packages {
214
202
npm install -- global -- silent $package
215
203
Write-PrettyOutput - Process " nvm" - Entry " npm:" - Entry2 " $package " - Message " installed successfully." - Extra
216
204
}
217
- }
218
- else {
205
+ } else {
219
206
foreach ($package in $packages ) {
220
207
Write-PrettyOutput - Process " nvm" - Entry " npm:" - Entry2 " $package " - Message " already installed. Skipping..." - Extra
221
208
}
@@ -229,10 +216,9 @@ function Install-Vagrant-Plugins {
229
216
$installed = (vagrant plugin list)
230
217
foreach ($plugin in $List ) {
231
218
if (! ($installed | Select-String " $plugin " )) {
232
- gum spin -- title= " Instaling plugin $plugin ..." -- vagrant plugin install $plugin
219
+ gum spin -- title= " Installing plugin $plugin ..." -- vagrant plugin install $plugin
233
220
Write-PrettyOutput - Process " vagrant" - Entry " plugin:" - Entry2 " $plugin " - Message " installed successfully." - Extra
234
- }
235
- else {
221
+ } else {
236
222
Write-PrettyOutput - Process " vagrant" - Entry " plugin:" - Entry2 " $plugin " - Message " already installed. Skipping..." - Extra
237
223
}
238
224
}
@@ -250,8 +236,7 @@ function Install-NerdFonts {
250
236
if (! ($installedFonts | Select-String " $fontName " )) {
251
237
& ([scriptblock ]::Create((Invoke-WebRequest ' https://to.loredo.me/Install-NerdFont.ps1' ))) - Confirm:$false - Scope AllUsers - Name $fontShortName
252
238
Write-PrettyOutput - Process " nerd font" - Entry " $fontName " - Message " installed successfully."
253
- }
254
- else {
239
+ } else {
255
240
Write-PrettyOutput - Process " nerd font" - Entry " $fontName " - Message " already installed. Skipping..."
256
241
}
257
242
}
@@ -270,8 +255,7 @@ function Set-Symlinks {
270
255
$symlinkFile | Remove-Item - Force - Recurse - ErrorAction SilentlyContinue
271
256
if (((Test-DeveloperMode ) -eq $False ) -and ((Test-IsElevated ) -eq $False )) {
272
257
gsudo { New-Item - ItemType SymbolicLink - Path $symlinkKey - Target $symLinkTarget - Force | Out-Null }
273
- }
274
- else {
258
+ } else {
275
259
New-Item - ItemType SymbolicLink - Path $symlinkKey - Target $symLinkTarget - Force | Out-Null
276
260
}
277
261
Write-PrettyOutput " symlink" - Entry " $symlinkKey " - Entry2 " => $symlinkTarget " - Message " added." - Extra
@@ -285,8 +269,7 @@ function Set-EnvironmentVariable {
285
269
if (! ([System.Environment ]::GetEnvironmentVariable(" $Value " ))) {
286
270
[System.Environment ]::SetEnvironmentVariable(" $Value " , " $Path " , " User" )
287
271
Write-PrettyOutput - Process " env" - Entry " $Value " - Entry2 " => $Path " - Message " added." - Extra
288
- }
289
- else {
272
+ } else {
290
273
Write-PrettyOutput - Process " env" - Entry " $Value " - Entry2 " => $Path " - Message " already set." - Extra
291
274
}
292
275
}
@@ -298,8 +281,7 @@ function Download-File {
298
281
)
299
282
if (Get-Command wget.exe - ErrorAction SilentlyContinue) {
300
283
& wget.exe -- quiet - P " $Directory " " $Url "
301
- }
302
- else {
284
+ } else {
303
285
Invoke-WebRequest - Uri " $Url " - OutFile " $Directory "
304
286
}
305
287
}
0 commit comments