-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows-dev-setup.ps1
More file actions
84 lines (69 loc) · 3.15 KB
/
windows-dev-setup.ps1
File metadata and controls
84 lines (69 loc) · 3.15 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
# Set execution policy so that the script can run successfully
Set-ExecutionPolicy Bypass -Scope Process -Force
# Function to check if a program is installed
function Is-Installed($name) {
Get-Command $name -ErrorAction SilentlyContinue -CommandType Application
}
# Function to set WSL as default profile in Windows Terminal
function Set-WSLDefaultProfile {
$settingsPath = "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
if (Test-Path $settingsPath) {
$settings = Get-Content $settingsPath -Raw | ConvertFrom-Json
$ubuntuProfile = $settings.profiles.list | Where-Object { $_.name -eq "Ubuntu-22.04" }
if ($ubuntuProfile) {
$settings.profiles.defaults = @{ source = $ubuntuProfile.source; name = $ubuntuProfile.name }
$settings.defaultProfile = $ubuntuProfile.guid
$settings | ConvertTo-Json -Depth 100 | Set-Content $settingsPath
Write-Host "Set Ubuntu-22.04 as the default profile in Windows Terminal."
} else {
Write-Host "Ubuntu-22.04 profile not found in Windows Terminal settings."
}
} else {
Write-Host "Windows Terminal settings file not found."
}
}
# Install Git using winget
if (-not (Is-Installed 'git')) {
winget install --id Git.Git -e --source winget
}
# Install OpenSSH Client
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
# Install Visual Studio Code using winget
if (-not (Is-Installed 'code')) {
winget install --id Microsoft.VisualStudioCode -e --source winget
}
# Install Windows Terminal using winget
if (-not (Is-Installed 'wt')) {
winget install --id Microsoft.WindowsTerminal -e --source winget
}
# Variable to track if WSL was installed
$wslInstalled = $false
# Install WSL and set up Ubuntu
if (-not (Is-Installed 'wsl')) {
# Enable WSL feature
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
# Enable Virtual Machine Platform feature
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
# Install Ubuntu 22.04
winget install --id Canonical.Ubuntu.2204 -e --source winget
# Set WSL 2 as default
wsl --set-default-version 2
$wslInstalled = $true
Write-Host "WSL is installed. Please restart your computer to complete the installation."
} else {
Write-Host "WSL is already installed."
}
Write-Host "Git, OpenSSH Client, Visual Studio Code, Windows Terminal, and WSL installation complete. The next step should be adding your SSH key to ~/.ssh/. Happy coding!"
# Prompt to restart the computer if WSL was installed
if ($wslInstalled) {
$setWSLasDefaultTerminal = Read-Host "Would you like to set WSL as the default profile of Windows Terminal? (yes/no)"
if ($setWSLasDefaultTerminal -eq 'yes' -or $setWSLasDefaultTerminal -eq 'y') {
Set-WSLDefaultProfile
}
$restart = Read-Host "Would you like to restart your computer now? (yes/no)"
if ($restart -eq 'yes' -or $restart -eq 'y') {
Restart-Computer
} else {
Write-Host "Please restart your computer at your convenience to complete the WSL installation."
}
}