-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup.ps1
106 lines (79 loc) · 3.33 KB
/
setup.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
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
#Requires -Version 5
if (($PSVersionTable.PSVersion.Major) -lt 5) {
Write-Output "PowerShell 5 or later is required to run."
break
}
$isadmin = (new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole("Administrators")
if (-not ($isadmin)) { throw "Must have Admininstrative Priveledges..." }
Write-Host "Configuring System..." -ForegroundColor "Yellow"
# Custom functions
function Hide-File {
param([Parameter(Mandatory)][string]$Path)
if (!(((Get-Item -Path $Path -Force).Attributes.ToString() -Split ", ") -Contains "Hidden")) {
(Get-Item -Path $Path -Force).Attributes += "Hidden"
}
}
function New-Directory {
param ([Parameter(Mandatory)][string]$Path, [switch]$Hide)
PROCESS {
If (!(test-path $Path)) {
New-Item -Path $Path -ItemType "directory" | Out-Null
}
if ($Hide) { Hide-File($Path) }
}
}
function Set-Softlink {
param ([Parameter(Mandatory)][string]$Path, [Parameter(Mandatory)][string]$Target, [switch]$Hide)
PROCESS {
if (Test-Path -Path $Path) {
if (!(Get-Item $Path -Force).LinkType -eq "SymbolicLink") {
Write-Host "Old file renamed to $((Get-Item -Path $Path).Name).old..." -ForegroundColor Blue
Rename-Item -Path $Path -NewName "$((Get-Item -Path $Path).Name).old"
Write-Host "Linking: $Target->$Path..." -ForegroundColor Blue
New-Item -ItemType SymbolicLink -Path $Path -Target $Target -Force | Out-Null
}
}
else {
Write-Host "Linking: $Target->$Path..." -ForegroundColor Blue
New-Item -ItemType SymbolicLink -Path $Path -Target $Target -Force | Out-Null
}
if ($Hide) { Hide-File($Path) }
}
}
function Find-Installed( $programName ) {
$x86_check = ((Get-ChildItem "HKLM:Software\Microsoft\Windows\CurrentVersion\Uninstall") |
Where-Object { $_."Name" -like "*$programName*" } ).Length -gt 0;
if (Test-Path 'HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') {
$x64_check = ((Get-ChildItem "HKLM:Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") |
Where-Object { $_."Name" -like "*$programName*" } ).Length -gt 0;
}
return $x86_check -or $x64_check;
}
# Trust PSrepository
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
# Create directories
New-Directory -Path "$HOME\.aws" -Hide
New-Directory -Path "$HOME\.azure" -Hide
New-Directory -Path "$HOME\repo"
New-Directory -Path "$HOME\.config" -Hide
# Windows
Invoke-Expression -Command "$PSScriptRoot\windows\setup.ps1"
# Winget
Invoke-Expression -Command "$PSScriptRoot\winget\setup.ps1"
# Visual Studio Code
Invoke-Expression -Command "$PSScriptRoot\vscode\setup.ps1"
# Git
Invoke-Expression -Command "$PSScriptRoot\git\setup.ps1"
# Powershell
Invoke-Expression -Command "$PSScriptRoot\powershell\setup.ps1"
# Anaconda / Miniconda
Invoke-Expression -Command "$PSScriptRoot\conda\setup.ps1"
# Bash
Invoke-Expression -Command "$PSScriptRoot\bash\setup.ps1"
# WSL
Invoke-Expression -Command "$PSScriptRoot\wsl\setup.ps1"
# Windows terminal
Invoke-Expression -Command "$PSScriptRoot\terminal\setup.ps1"
# GPG
Invoke-Expression -Command "$PSScriptRoot\gpg\setup.ps1"
Write-Host "Setup finished." -ForegroundColor Green