mirror of
https://github.com/Baipyrus/dotfiles.git
synced 2024-12-25 10:51:46 +00:00
Compare commits
17 Commits
24b6d1f115
...
e1029ae1cd
Author | SHA1 | Date | |
---|---|---|---|
e1029ae1cd | |||
3e07cfaa12 | |||
b5a56cd60e | |||
8995565e26 | |||
97fcc961a7 | |||
94028eff12 | |||
8a4fed4295 | |||
fa7d942a8f | |||
107b83ced4 | |||
80a34d44c3 | |||
7e8bc5fa19 | |||
7aa94ca8e2 | |||
0da955a90d | |||
cf885e7363 | |||
72061fd686 | |||
1d33d6ed32 | |||
4ce997d016 |
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user