-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbootstrap.ps1
190 lines (148 loc) · 5.29 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
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
# improve powershell performance
$ProgressPreference = 'SilentlyContinue'
# setup git
git config --global user.name 'jonz94'
git config --global user.email '[email protected]'
git config --global pull.rebase true
git config --global init.defaultBranch main
# create local profile if it does not exist
$localScript = Join-Path $PSScriptRoot 'local\local.ps1'
if (-not $(Test-Path $localScript -PathType Leaf)) {
New-Item $localScript -ItemType File -Force *> $null
}
# create $PROFILE file if it does not exists
if (-not $(Test-Path $PROFILE -PathType Leaf)) {
New-Item $PROFILE -ItemType File -Force *> $null
}
# source main profile
if (-not $(Select-String -Path $PROFILE -Pattern '^\. \$HOME\\dotfiles\\powershell\\jonz94\.ps1$')) {
Add-Content $PROFILE -Encoding UTF8 -Value '. $HOME\dotfiles\powershell\jonz94.ps1'
}
# source local profile
if (-not $(Select-String -Path $PROFILE -Pattern '^\. \$HOME\\dotfiles\\local\\local\.ps1$')) {
Add-Content $PROFILE -Encoding UTF8 -Value '. $HOME\dotfiles\local\local.ps1'
}
$currentScoopBucketList = $(scoop bucket list).Name
if (-not $currentScoopBucketList.Contains('main')) {
scoop bucket add main
}
if (-not $currentScoopBucketList.Contains('extras')) {
scoop bucket add extras
}
if (-not $currentScoopBucketList.Contains('nerd-fonts')) {
scoop bucket add nerd-fonts
}
if (-not $currentScoopBucketList.Contains('sarasa-nerd-fonts')) {
scoop bucket add sarasa-nerd-fonts https://github.com/jonz94/scoop-sarasa-nerd-fonts
}
if (-not $currentScoopBucketList.Contains('jonz94')) {
scoop bucket add jonz94 https://github.com/jonz94/scoop-personal
}
# install oh-my-posh
if (-not $(scoop which oh-my-posh)) {
scoop install oh-my-posh
}
# install gsudo
if (-not $(scoop which gsudo)) {
scoop install gsudo
}
# install neovim bare nightly
if (-not $(scoop which nvim)) {
scoop install neovim-bare-nightly
}
# install fzf
if (-not $(scoop which fzf)) {
scoop install fzf
}
# install fzf powershell module
if (-not $(scoop which psfzf)) {
scoop install psfzf
}
# install fnm
if (-not $(scoop which fnm)) {
scoop install fnm
}
# install zoxide
if (-not $(scoop which zoxide)) {
scoop install zoxide
}
# install busybox-lean
if (-not $(scoop which busybox)) {
scoop install busybox-lean
}
# install ripgrep
if (-not $(scoop which ripgrep)) {
scoop install ripgrep
}
# install grep
if (-not $(scoop which grep)) {
scoop install grep
}
# install less
if (-not $(scoop which less)) {
scoop install less
}
# install sed
if (-not $(scoop which sed)) {
scoop install sed
}
# install Sarasa Gothic fonts
if (-not $(scoop which SarasaGothic-ttc)) {
scoop install SarasaGothic-ttc
}
# install Sarasa Mono TC Nerd Font
if (-not $(scoop which sarasa-mono-tc-nerd-font)) {
scoop install sarasa-mono-tc-nerd-font
}
# add scoop commmand aliases
scoop alias add upgrade 'scoop update --all' 'Updates all apps, just like brew or apt'
scoop alias add reinstall 'scoop uninstall $args[0]; scoop install $args[0]' 'Reinstall an app'
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
# install posh-git module
if ( (-not $(Get-InstalledModule)) -or (-not $(Get-InstalledModule).Name.contains('posh-git')) ) {
Install-Module 'posh-git' -Scope CurrentUser
}
# install Terminal-Icons module
if (-not $(scoop which terminal-icons)) {
scoop install terminal-icons
}
# load fnm & generate fnm's completions file
$fnmCompletionsPs1Path = Join-Path $PSScriptRoot 'powershell\completions\_fnm.completions.ps1'
if (-not $(Test-Path $fnmCompletionsPs1Path -PathType Leaf)) {
$commands = @'
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
fnm env --use-on-cd | Out-String | Invoke-Expression
fnm completions --shell power-shell
'@
powershell.exe -NoProfile -Command "$commands > $fnmCompletionsPs1Path"
}
# load fnm, remove corepack, install pnpm and yarn
$setupNodejsEnvironmentViaFnmCommands = @'
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
fnm env --use-on-cd | Out-String | Invoke-Expression
fnm install --lts
fnm alias lts-latest default
npm i -g npm@latest
npm rm -g corepack
npm i -g pnpm@latest yarn@latest
'@
powershell.exe -NoProfile -Command $setupNodejsEnvironmentViaFnmCommands
# load fnm & generate pnpm's completions file
$pnpmCompletionsPs1Path = Join-Path $PSScriptRoot 'powershell\completions\_pnpm.completions.ps1'
if (-not $(Test-Path $pnpmCompletionsPs1Path -PathType Leaf)) {
$commands = @'
Set-ExecutionPolicy RemoteSigned -scope CurrentUser
fnm env --use-on-cd | Out-String | Invoke-Expression
pnpm completion --shell pwsh
'@
powershell.exe -NoProfile -Command "$commands > $pnpmCompletionsPs1Path"
}
Write-Host "`nINFO: execute following script to setup neovim:`n" -ForegroundColor Cyan
Write-Host " .\powershell\scripts\setup-neovim.ps1`n" -ForegroundColor Blue
Write-Host "`nINFO: execute following script to setup vscode snippets:`n" -ForegroundColor Cyan
Write-Host " .\powershell\scripts\setup-vscode-snippets.ps1`n" -ForegroundColor Blue
Write-Host "`nINFO: execute following script to setup vsvimrc:`n" -ForegroundColor Cyan
Write-Host " .\powershell\scripts\setup-vsvimrc.ps1`n" -ForegroundColor Blue
Write-Host "`nINFO: execute following script to setup ideavimrc:`n" -ForegroundColor Cyan
Write-Host " .\powershell\scripts\setup-ideavimrc.ps1`n" -ForegroundColor Blue
Write-Host 'Done! 🎉'