-
Notifications
You must be signed in to change notification settings - Fork 3
/
init.ps1
72 lines (63 loc) · 1.8 KB
/
init.ps1
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
Start-Transcript $ENV:TEMP\winconf.log -Append
$root = "$env:userprofile\winconf"
$scripts_dir = "$root\scripts"
$repoUrl = '[email protected]:asolopovas/winconf.git'
$autohotkeyVersion = 2
$essential_software = @(
'Microsoft.Powershell'
'voidtools.Everything'
'junegunn.fzf'
'Git.Git'
'Starship.Starship'
'AutoHotkey.AutoHotkey'
)
$source_files = @(
'Bloatware-Removal'
'Cleanup'
'Setup-EnvironmentPaths'
'Setup-NerdFonts'
'Setup-Powershell'
'Setup-Terminal'
'Setup-Autohotkey'
'Setup-DirectoryOpus'
'Setup-OpenSSH'
)
function Test-CommandExists {
Param ($command)
$oldPreference = $ErrorActionPreference
$ErrorActionPreference = "stop"
try { if (Get-Command $command) { return $true } }
Catch { return $false }
Finally { $ErrorActionPreference = $oldPreference }
}
function SourceFile {
param($file)
Write-Host "`nSourcing $file ..." -ForegroundColor DarkCyan
if ($file -eq 'Setup-Autohotkey') {
& "$scripts_dir\$file.ps1" -version $autohotkeyVersion
}
else {
& "$scripts_dir\$file.ps1"
}
}
foreach ($soft in $essential_software) {
Write-Host "Installing $soft... " -ForegroundColor DarkGray
winget install --id $soft -h --disable-interactivity
}
if ($args[0] -eq '--software') {
$source_files += 'Install-Software'
}
foreach ($file in $source_files) {
SourceFile $file
}
$gitPath = "$env:ProgramFiles\Git\cmd"
$env:PATH += ";$gitPath"
if (!(Test-Path -Path $root)) {
Write-Host "Cloning repository into $root..." -ForegroundColor DarkGray
git clone $repoUrl $root
}
else {
Write-Host "$root already exists. Pulling the latest changes..." -ForegroundColor DarkGray
Set-Location -Path $root
git pull
}