diff options
| -rw-r--r-- | .config/powershell/bootstrap.ps1 | 123 |
1 files changed, 59 insertions, 64 deletions
diff --git a/.config/powershell/bootstrap.ps1 b/.config/powershell/bootstrap.ps1 index 5747214..53ec1b0 100644 --- a/.config/powershell/bootstrap.ps1 +++ b/.config/powershell/bootstrap.ps1 @@ -4,93 +4,89 @@ # Write-Host ---------------------------------------- # Set-ExecutionPolicy Unrestricted - -# Install NVM -Write-Host Configuring NVM -Write-Host ---------------------------------------- -$installPath = "C:\Users\%USERPROFILE%\AppData\Roaming\nvm" -if (-not (Test-Path -Path $installPath)) -{ - $nvmUrl = "https://github.com/coreybutler/nvm-windows/releases/latest/download/nvm-setup.zip" - $extractPath = "C:\Temp\nvm\" - $downloadZipFile = $extractPath + $(Split-Path -Path $nvmUrl -Leaf) - mkdir $extractPath - Invoke-WebRequest -Uri $nvmUrl -OutFile $downloadZipFile - $extractShell = New-Object -ComObject Shell.Application - $extractFiles = $extractShell.Namespace($downloadZipFile).Items() - $extractShell.NameSpace($extractPath).CopyHere($extractFiles) - pushd $extractPath - Start-Process .\nvm-setup.exe -Wait - popd - Read-Host -Prompt "Setup done, now close the command window, and run this script again in a new elevated window. Press any key to continue" - Exit -} -else -{ - Write-Host Detected that NVM is already installed, so now using it to install NodeJS LTS - pushd $installPath - .\nvm.exe install lts - .\nvm.exe use lts - popd +# Function to check if NVM is installed +function Test-NVMInstalled { + $nvmPath = "$env:USERPROFILE\AppData\Roaming\nvm\nvm.exe" + return Test-Path -Path $nvmPath } +# Install NVM if not installed +Write-Host "Configuring NVM" +Write-Host "----------------------------------------" +if (-not (Test-NVMInstalled)) { + Write-Host "NVM is not installed. Proceeding with installation." + $nvmUrl = "https://github.com/coreybutler/nvm-windows/releases/latest/download/nvm-setup.zip" + $extractPath = "C:\Temp\nvm\" + $downloadZipFile = $extractPath + (Split-Path -Path $nvmUrl -Leaf) + mkdir $extractPath -ErrorAction SilentlyContinue + Invoke-WebRequest -Uri $nvmUrl -OutFile $downloadZipFile + $extractShell = New-Object -ComObject Shell.Application + $extractFiles = $extractShell.Namespace($downloadZipFile).Items() + $extractShell.NameSpace($extractPath).CopyHere($extractFiles) + pushd $extractPath + Start-Process .\nvm-setup.exe -Wait + popd + Read-Host -Prompt "Setup done, now close the command window, and run this script again in a new elevated window. Press any key to continue" + Exit +} else { + Write-Host "Detected that NVM is already installed. Now using it to install NodeJS LTS." + $nvmPath = "$env:USERPROFILE\AppData\Roaming\nvm" + pushd $nvmPath + .\nvm.exe install lts + .\nvm.exe use lts + popd +} # WSL -Write-Host Configuring WSL +Write-Host "Configuring WSL" wsl --install -d Ubuntu - # Install Chocolatey -Write-Host Install Chocolatey -Write-Host ---------------------------------------- -Set-ExecutionPolicy Bypass -Scope Process -Force; -[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; +Write-Host "Installing Chocolatey" +Write-Host "----------------------------------------" +Set-ExecutionPolicy Bypass -Scope Process -Force +[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - # Install Applications -Write-Host Install Applications -Write-Host ---------------------------------------- -choco install ripgrep # https://github.com/BurntSushi/ripgrep -choco install fd # https://github.com/sharkdp/fd -choco install sudo # ALLOWS USING sudo IN POWERSHELL! -choco install win32yank # Neovim clipboard support in WSL, FROM: https://stackoverflow.com/a/67229362/182888 - +Write-Host "Installing Applications" +Write-Host "----------------------------------------" +choco install ripgrep -y +choco install fd -y +choco install sudo -y +choco install win32yank -y # Configure Neovim -Write-Host Configuring Neovim -Write-Host ---------------------------------------- +Write-Host "Configuring Neovim" +Write-Host "----------------------------------------" New-Item -ItemType Junction -Force ` - -Path "$home\AppData\Local\nvim" ` - -Target "$home\.config\nvim" - + -Path "$home\AppData\Local\nvim" ` + -Target "$home\.config\nvim" -# Install Windows Terminal -Write-Host Install Windows Terminal, and configure -Write-Host ---------------------------------------- +# Install Windows Terminal, and configure +Write-Host "Install Windows Terminal, and configure" +Write-Host "----------------------------------------" Move-Item -Force "$home\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" "$home\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json.old" New-Item -ItemType HardLink -Force ` - -Path "$home\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" ` - -Target "$home\.config\windows-terminal\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" - + -Path "$home\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" ` + -Target "$home\.config\windows-terminal\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" -# Configure Powershell -Write-Host Configuring PowerShell -Write-Host ---------------------------------------- +# Configure PowerShell +Write-Host "Configuring PowerShell" +Write-Host "----------------------------------------" New-Item -ItemType HardLink -Force ` - -Path "$home\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" ` - -Target "$home\.config\powershell\Microsoft.PowerShell_profile.ps1" - + -Path "$home\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" ` + -Target "$home\.config\powershell\Microsoft.PowerShell_profile.ps1" # Registry Tweaks -Write-Host Registry Tweaks -Write-Host ---------------------------------------- +Write-Host "Registry Tweaks" +Write-Host "----------------------------------------" # Show hidden files -Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name Hidden 1 +Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name Hidden -Value 1 # Show file extensions for known file types -Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name HideFileExt 0 +Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name HideFileExt -Value 0 # Never Combine taskbar buttons when the taskbar is full Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name TaskbarGlomLevel -Value 2 @@ -101,7 +97,6 @@ Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer # Set Windows to use UTC time instead of local time for system clock Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name RealTimeIsUniversal -Value 1 - # Function to check if the current session is elevated function Test-IsAdmin { $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() |
