-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetup-Dev.ps1
More file actions
142 lines (111 loc) · 5.54 KB
/
Setup-Dev.ps1
File metadata and controls
142 lines (111 loc) · 5.54 KB
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
######
#
# Setup-Dev.ps1
#
# fdcastel@gmail.com
#
###
#
# Functions
#
function Update-SessionPath {
# Updates current session PATH reading the most updated one from Registry
$env:Path = (Get-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Session Manager\Environment').Path + ';' + `
(Get-ItemProperty 'HKCU:\Environment').Path
}
function Merge-JsonObject {
param(
[Parameter(Mandatory = $true)]
[pscustomobject]$Base,
[Parameter(Mandatory = $true)]
[pscustomobject]$Overlay
)
foreach ($overlayProperty in $Overlay.PSObject.Properties) {
$propertyName = $overlayProperty.Name
$overlayValue = $overlayProperty.Value
$baseProperty = $Base.PSObject.Properties[$propertyName]
if ($null -eq $baseProperty) {
$Base | Add-Member -MemberType NoteProperty -Name $propertyName -Value $overlayValue
continue
}
$baseValue = $baseProperty.Value
if ( ($baseValue -is [pscustomobject]) -and ($overlayValue -is [pscustomobject]) ) {
Merge-JsonObject -Base $baseValue -Overlay $overlayValue | Out-Null
}
}
return $Base
}
function Save-JsonAsUtf8WithoutBom {
param(
[Parameter(Mandatory = $true)]
[string]$FilePath,
[Parameter(Mandatory = $true)]
$Data
)
$json = $Data | ConvertTo-Json -Depth 100
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllLines($FilePath, @($json), $utf8NoBom)
}
function Merge-RemoteJsonIntoFile {
param(
[Parameter(Mandatory = $true)]
[string]$FilePath,
[Parameter(Mandatory = $true)]
[string]$JsonUrl
)
$defaultSettings = Invoke-WebRequest -Uri $JsonUrl -UseBasicParsing |
Select-Object -ExpandProperty Content |
ConvertFrom-Json
if (Test-Path $FilePath) {
$existingSettings = Get-Content -Path $FilePath -Raw | ConvertFrom-Json
$mergedSettings = Merge-JsonObject -Base $existingSettings -Overlay $defaultSettings
}
else {
$mergedSettings = $defaultSettings
}
Save-JsonAsUtf8WithoutBom -FilePath $FilePath -Data $mergedSettings
}
#
# Main
#
$ErrorActionPreference = 'Stop' # Stop on any error
$ProgressPreference = 'SilentlyContinue' # Disable progress bar.
# Install Beyond Compare
choco upgrade beyondcompare -y
# Install Git
choco upgrade git -y
Update-SessionPath
# Remove Git Windows Explorer context menu entries
Remove-Item -Path "HKLM:\SOFTWARE\Classes\Directory\background\shell\git_gui" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "HKLM:\SOFTWARE\Classes\Directory\background\shell\git_shell" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\git_gui" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\Directory\shell\git_shell" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_gui" -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item -Path "Registry::HKEY_CLASSES_ROOT\LibraryFolder\background\shell\git_shell" -Force -Recurse -ErrorAction SilentlyContinue
# Configure Git
git config --global user.email fdcastel@gmail.com
git config --global user.name F.D.Castel
# Install TortoiseGit
choco upgrade tortoisegit -y
# Configure TortoiseGit menus
# - Main: Clone, Pull, Push, Commit, Show log, Check for modifications, Switch/Checkout, Create Branch
# - Shift pressed: Clone, Create repository here
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name 'ContextMenuEntries' -PropertyType 'DWORD' -Value 0x00120c84 | Out-Null
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name 'ContextMenuEntriesHigh' -PropertyType 'DWORD' -Value 0x00000038 | Out-Null
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name 'ContextMenuExtEntriesLow' -PropertyType 'DWORD' -Value 0x40000400 | Out-Null
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name 'ContextMenuExtEntriesHigh' -PropertyType 'DWORD' -Value 0x00012020 | Out-Null
# Configure TortoiseGit / Beyond Compare integration
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name Diff -PropertyType String -Value '"C:\Program Files\Beyond Compare 5\BComp.exe" %base %mine /title1=%bname /title2=%yname /leftreadonly' | Out-Null
New-ItemProperty HKCU:\Software\TortoiseGit -Force -Name Merge -PropertyType String -Value '"C:\Program Files\Beyond Compare 5\BComp.exe" %mine %theirs %base %merged /title1=%yname /title2=%tname /title3=%bname /title4=%mname' | Out-Null
# Install Visual Studio Code, GitHub CLI and Claude Code
choco upgrade vscode gh claude-code -y
# Download Claude settings and merge them with the current user's settings
$claudeConfigDir = Join-Path -Path $env:USERPROFILE -ChildPath '.claude'
New-Item -Path $claudeConfigDir -ItemType Directory -Force | Out-Null
$claudeSettingsFile = Join-Path -Path $claudeConfigDir -ChildPath 'settings.json'
Merge-RemoteJsonIntoFile -FilePath $claudeSettingsFile -JsonUrl 'https://raw.githubusercontent.com/fdcastel/setup/master/claude/default-settings.json'
# Download VS Code default settings and merge with the current user's settings
$vsCodeUserDir = Join-Path -Path $env:APPDATA -ChildPath 'Code\User'
New-Item -Path $vsCodeUserDir -ItemType Directory -Force | Out-Null
$vsCodeSettingsFile = Join-Path -Path $vsCodeUserDir -ChildPath 'settings.json'
Merge-RemoteJsonIntoFile -FilePath $vsCodeSettingsFile -JsonUrl 'https://raw.githubusercontent.com/fdcastel/setup/master/vscode/default-settings.json'