Compare commits

...

17 Commits

Author SHA1 Message Date
e1029ae1cd bugfix: actually using newly specified parameter 2024-11-25 15:35:53 +01:00
3e07cfaa12 replace with Invoke-WebRequest for optimizations in commit fa7d942 2024-11-25 15:33:04 +01:00
b5a56cd60e ignore command output for commit 94028ef 2024-11-25 15:31:27 +01:00
8995565e26 bugfix: accidentally merged output of commands 2024-11-25 15:28:58 +01:00
97fcc961a7 bugfix: save detected dotfiles repo location 2024-11-25 15:21:47 +01:00
94028eff12 bugfix: create powershell profile directory if not exists 2024-11-25 15:10:09 +01:00
8a4fed4295 bugfix: fix filepath when calling from local dir 2024-11-25 15:06:01 +01:00
fa7d942a8f optimize download without progressbar 2024-11-25 15:03:16 +01:00
107b83ced4 bugfix: create local user fonts directory if not exists 2024-11-25 14:34:36 +01:00
80a34d44c3 bugfix: renamed function parameter in 5090a04 2024-11-25 14:25:44 +01:00
7e8bc5fa19 bugfix: fix command to add user to sudoers group 2024-11-25 12:18:39 +01:00
7aa94ca8e2 provide additional user feedback with consistent style 2024-11-25 12:00:30 +01:00
0da955a90d replace dism.exe for CMD with builtin powershell module 2024-11-25 11:56:41 +01:00
cf885e7363 using wsl install without distro for older versions 2024-11-25 11:54:14 +01:00
72061fd686 remove excess colon in after install prompt 2024-11-25 11:45:47 +01:00
1d33d6ed32 optimize download without progressbar 2024-11-25 11:35:19 +01:00
4ce997d016 replace builtin install method with web request to app installer 2024-11-25 11:26:55 +01:00
4 changed files with 52 additions and 23 deletions

View File

@ -10,7 +10,7 @@ ChocolateyInstall
WSLInstall
Write-Host "Installation Steps complete!" -ForegroundColor Cyan
$continue = Read-Host "Continue with configuration? [Y/n]:"
$continue = Read-Host "Continue with configuration? [Y/n]"
if ($continue.ToLower() -eq 'n')
{ return
}
@ -26,7 +26,7 @@ $repoUrl = "https://github.com/Baipyrus/dotfiles.git"
$currentDir = (Get-Location).Path
ReadyDotfilesRepo -cwd $currentDir -url $repoUrl -destination $dotfilesRepo
$dotfilesRepo = ReadyDotfilesRepo -cwd $currentDir -url $repoUrl -destination $dotfilesRepo
# Setting up Alacritty Configuration
Write-Host "Setting up Alacritty configuration..." -ForegroundColor Cyan
@ -46,6 +46,12 @@ if ($null -eq $ubuntu)
# Setting up PowerShell Profile
Write-Host "Setting up PowerShell profile..." -ForegroundColor Cyan
# Create local PowerShell profile directory
$psDir = Split-Path -Path $psProfile
if (-not (Test-Path $psDir))
{ New-Item -ItemType Directory -Path $psDir | Out-Null
}
# Copy existing startup script to destination
CopyFileWithPrompt "$dotfilesRepo\PowerShell\Microsoft.PowerShell_profile.ps1" $psProfile
# Setting up self-made ProxySwitcher
@ -56,7 +62,7 @@ Write-Host "============================================" -ForegroundColor DarkG
# Installing Nerd Fonts
Write-Host "Installing Nerd Fonts..." -ForegroundColor Cyan
ProcessUrlFiles -source "$dotfilesRepo\nerd-fonts" -fileExt ".zip"
ProcessUrlFiles -source "$dotfilesRepo\nerd-fonts" -fileExt ".zip" -progress $false
UnzipAndInstall -source "$dotfilesRepo\nerd-fonts"
# Final message

View File

@ -29,7 +29,7 @@ function ReadyDotfilesRepo
if (IsGitRepository -dir $cwd -url $url)
{
Write-Host "Already inside the dotfiles repository. Skipping clone step and pulling..." -ForegroundColor Yellow
git pull
Write-Host "$(git pull)"
return $cwd
}
@ -48,7 +48,7 @@ function ReadyDotfilesRepo
}
Write-Host "Pulling latest changes from dotfiles repository..." -ForegroundColor Cyan
git -C $destination pull
Write-Host "$(git -C $destination pull)"
return $destination
}
@ -78,9 +78,16 @@ function ProcessUrlFiles
param (
[string]$source,
[Parameter(Mandatory=$false)][string]$destination,
[Parameter(Mandatory=$false)][string]$fileExt
[Parameter(Mandatory=$false)][string]$fileExt,
[bool]$progress=$true
)
# Disable progressbar for faster download
$progressPreference = 'continue'
if (-not $progress)
{ $progressPreference = 'silentlyContinue'
}
# Ensure the destination directory exists
if ($destination -and (-not (Test-Path $destination)))
{
@ -125,7 +132,7 @@ function ProcessUrlFiles
}
Write-Host "Downloading $fileName from $url$conditional..." -ForegroundColor Cyan
Invoke-RestMethod $url -OutFile $fileName$extension
Invoke-WebRequest $url -OutFile $fileName$extension
$tmpDestination = "$tmpApp\$fileName$extension"
# Copy only if destination is provided
@ -168,6 +175,11 @@ function UnzipAndInstall
{ New-Item -ItemType Directory -Path $tmpApp | Out-Null
}
$destination = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts\"
if (-not (Test-Path $destination))
{ New-Item -ItemType Directory -Path $destination | Out-Null
}
# Find all .url files in the source directory
$urlFiles = Get-ChildItem -Path $source -Filter '*.url'
@ -178,6 +190,6 @@ function UnzipAndInstall
Expand-Archive "$tmpApp\$fileName.zip" -DestinationPath "$tmpApp\$fileName" | Out-Null
Write-Host "Installing fonts from $tmpApp\$fileName\ for current user..." -ForegroundColor Cyan
Copy-Item -Path "$tmpApp\$fileName\*" -Destination "$env:LOCALAPPDATA\Microsoft\Windows\Fonts\" -Force -ErrorAction SilentlyContinue
Copy-Item -Path "$tmpApp\$fileName\*" -Destination $destination -Force -ErrorAction SilentlyContinue
}
}

View File

@ -1,12 +1,22 @@
function InstallWinget
{
# Reference: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox
$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager
$download = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
$setup = "$env:TMP\winget_setup.msixbundle"
if (-not (Test-Path $setup))
{
$releases = Invoke-RestMethod $download
$assets = $releases | Select-Object -ExpandProperty "assets"
$installer = $assets | Where-Object "name" -Match "msixbundle"
$url = $installer | Select-Object -ExpandProperty "browser_download_url"
Write-Host "Downloading WinGet '.msixbundle' installer ..."
Invoke-WebRequest $url -OutFile $setup
}
Write-Host "Installing WinGet app package..."
Add-AppxPackage -Path $setup
}
function WingetInstall

View File

@ -1,9 +1,10 @@
function InstallWSL
{
# Reference: https://learn.microsoft.com/en-us/windows/wsl/install-manual
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
wsl.exe --update
Write-Host "Enabling and downloading required Windows Features..."
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All -NoRestart | Out-Null
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -All -NoRestart | Out-Null
Write-Host "Installing WSL2..."
wsl.exe --install --no-distribution
wsl.exe --set-default-version 2
}
@ -34,8 +35,8 @@ function WSLInstall
wsl.exe --install -d Ubuntu
# Add newly created user to sudoers group
$user = wsl.exe cut "-d:" "-f1" /etc/passwd
wsl.exe -u root echo "echo ""$user ALL=(ALL) NOPASSWD:ALL"" >> /etc/sudoers.d/$user"
$user = wsl.exe cut "-d:" "-f1" /etc/passwd | Select-Object -Last 1
wsl.exe -u root echo "$user ALL=(ALL) NOPASSWD:ALL" ">>" "/etc/sudoers.d/$user"
# Update packages and install from list
wsl.exe sudo apt update "&&" sudo apt upgrade "-y"
@ -48,12 +49,12 @@ function InstallWSLNeovim
[string]$source
)
Import-Module ./windows.psm1
ProcessUrlFiles -sourceDir $source
Import-Module ./util/windows.psm1
Push-Location
ProcessUrlFiles -source $source
Set-Location "$env:TMP\nvim-config"
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
Pop-Location