-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.ps1
156 lines (121 loc) · 7.04 KB
/
bootstrap.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
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
#Requires -RunAsAdministrator
. ".\utils.ps1"
$script:binPath = "C:\bin"
$script:tempPath = "C:\temp"
$script:gnupgPath = ""
$script:winBuild = [System.Environment]::OSVersion.Version.Build
#We need bin and temp
CreateDirIfNotExist($script:binPath)
CreateDirIfNotExist($script:tempPath)
$script:y = new-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Yes";
$script:n = new-Object System.Management.Automation.Host.ChoiceDescription "&No", "No";
$script:choices = [System.Management.Automation.Host.ChoiceDescription[]]($script:y, $script:n);
#Applications
########################################################################################################################################################
########################################################################################################################################################
$script:answer = $host.ui.PromptForChoice("", "Install Applications?", $choices, 0)
if ($script:answer -eq 0) {
Write-Output ""
Write-Output "Installing applications from package manager(s)..."
#Chocolatey
Install 7zip
Install powershell-core "--install-arguments=""ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1"""
Install nano
Install awk #Not included with gnuWin32-coreutils.Install
Install gnuwin32-coreutils.install #Doesn't add to path automatically, do so below
if (-not ($env:PATH -like "*GNUWin32*")) {
Set-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment" -Name PATH -Value "$ENV:PATH;C:\Program Files (x86)\GnuWin32\bin"
}
Install vscode "/NoDesktopIcon"
Install sublimemerge
Install everything "/client-service /folder-context-menu"
Install screentogif
Install microsoft-windows-terminal
Install nerdfont-hack
#Scoop
scoop bucket add extras
scoop install posh-git
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json #this is from https://ohmyposh.dev/docs/windows/#installation
scoop install sudo
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
winget install "openssh beta" --force
}
#Misc File Links
########################################################################################################################################################
########################################################################################################################################################
$script:answer = $host.ui.PromptForChoice("", "Link Configs?", $choices, 0)
if ($script:answer -eq 0) {
Write-Output ""
Write-Output "Linking Misc Config files"
#Powershell profile(s)
$local:profileDir = [Environment]::GetFolderPath("MyDocuments")
lns "$local:profileDir\WindowsPowershell" ".\powershell"
lns "$local:profileDir\Powershell" ".\powershell"
# reload profile??
& $profile
if ($script:winBuild -ge 18362) { # Windows Terminal wont install on older versions of windows (Such as works LTSC)
#Windows Terminal Configs and shims
lns "$env:UserProfile\AppData\Local\Microsoft\Windows Terminal\settings.json" ".\windows-terminal\settings.json"
}
else {
# Fine. We'll work without the sexy Windows terminal by using intergrated term in vscode/vs
# However, in LTSC the console doesn't display ANSI colors correctly
# https://superuser.com/a/1300251
Set-ItemProperty -Path HKCU:\Console -Name VirtualTerminalLevel -Value 1
# BUT (and this is different from latest win10) it can use Hack NF font face. So that's OK-ish
Set-ItemProperty -Path HKCU:\Console -Name FaceName -Value "Hack NF"
set-ItemProperty -Path HKCU:\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe -Name FaceName -Value "Hack NF"
set-ItemProperty -Path HKCU:\Console\%SystemRoot%_SysWOW64_WindowsPowerShell_v1.0_powershell.exe -Name FaceName -Value "Hack NF"
# (Cant be bothered to go back to conemu. Maybe one day... Or maybe I'll just install it
# seperately outside of dotfiles on machines that don't let me use Windows Terminal)
}
}
#.gitconfig stuff
########################################################################################################################################################
########################################################################################################################################################
$script:answer = $host.ui.PromptForChoice("", "Conigure git?", $choices, 0)
if ($script:answer -eq 0) {
Write-Output ""
Write-Output "Copying .gitconfig and .gitignore"
lns "$env:UserProfile\.gitconfig" ".\git\.gitconfig"
lns "$env:UserProfile\.git-templates" ".\git\.git-templates"
}
#Dotfiles repo
########################################################################################################################################################
########################################################################################################################################################
#If this dotfiles repo has been installed via install.ps1, it wont be a repo, so need to init the folder and add remote.
$script:dotPath = "$env:UserProfile\.dotfiles"
Push-Location $script:dotPath
$local:tmpGitRemoteUrl = git remote get-url origin --push
$local:GitRemoteUrl = "[email protected]:PromoFaux/.dotfiles-win.git"
if (!($local:tmpGitRemoteUrl -eq $local:GitRemoteUrl)) {
Write-Output ""
Write-Output "Configuring dotfiles repo to use SSH remote rather than https"
git remote remove origin
git remote add origin $local:GitRemoteUrl
#git fetch
}
Pop-Location
# #Check the Yubikey batch file works works
# ########################################################################################################################################################
# ########################################################################################################################################################
# $script:answer = $host.ui.PromptForChoice("Test Yubikey?","Might require a reboot to work" , $choices, 0)
# if ($script:answer -eq 0) {
# Write-Output ""
# Write-Output "Insert your YubiKey now!"
# WaitForProcessToStart "wsl-ssh-pageant"
# [string[]]$local:validSSHKeys = Get-Content -Path '.\ssh\authorized_keys'
# $local:wait = $true
# while ($local:wait -eq $true) {
# $local:sshKeyOnCard = ssh-add -L
# # //if (!($local:test -eq $script:expectedSSHKey)) {
# if (!($local:validSSHKeys -contains $local:sshKeyOnCard)) {
# Write-Output "wsl-ssh-pageant is running but cannot get SSH key"
# Start-Sleep -s 3
# }
# else {
# Write-Output "SSH Key is as expected, so everything should be working!"
# $local:wait = $false
# }
# }
# }