mirror of
https://github.com/Baipyrus/dotfiles.git
synced 2024-12-26 03:11:45 +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
|
WSLInstall
|
||||||
|
|
||||||
Write-Host "Installation Steps complete!" -ForegroundColor Cyan
|
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')
|
if ($continue.ToLower() -eq 'n')
|
||||||
{ return
|
{ return
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ $repoUrl = "https://github.com/Baipyrus/dotfiles.git"
|
|||||||
$currentDir = (Get-Location).Path
|
$currentDir = (Get-Location).Path
|
||||||
|
|
||||||
|
|
||||||
ReadyDotfilesRepo -cwd $currentDir -url $repoUrl -destination $dotfilesRepo
|
$dotfilesRepo = ReadyDotfilesRepo -cwd $currentDir -url $repoUrl -destination $dotfilesRepo
|
||||||
|
|
||||||
# Setting up Alacritty Configuration
|
# Setting up Alacritty Configuration
|
||||||
Write-Host "Setting up Alacritty configuration..." -ForegroundColor Cyan
|
Write-Host "Setting up Alacritty configuration..." -ForegroundColor Cyan
|
||||||
@ -46,6 +46,12 @@ if ($null -eq $ubuntu)
|
|||||||
|
|
||||||
# Setting up PowerShell Profile
|
# Setting up PowerShell Profile
|
||||||
Write-Host "Setting up PowerShell profile..." -ForegroundColor Cyan
|
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
|
CopyFileWithPrompt "$dotfilesRepo\PowerShell\Microsoft.PowerShell_profile.ps1" $psProfile
|
||||||
|
|
||||||
# Setting up self-made ProxySwitcher
|
# Setting up self-made ProxySwitcher
|
||||||
@ -56,7 +62,7 @@ Write-Host "============================================" -ForegroundColor DarkG
|
|||||||
|
|
||||||
# Installing Nerd Fonts
|
# Installing Nerd Fonts
|
||||||
Write-Host "Installing Nerd Fonts..." -ForegroundColor Cyan
|
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"
|
UnzipAndInstall -source "$dotfilesRepo\nerd-fonts"
|
||||||
|
|
||||||
# Final message
|
# Final message
|
||||||
|
@ -29,7 +29,7 @@ function ReadyDotfilesRepo
|
|||||||
if (IsGitRepository -dir $cwd -url $url)
|
if (IsGitRepository -dir $cwd -url $url)
|
||||||
{
|
{
|
||||||
Write-Host "Already inside the dotfiles repository. Skipping clone step and pulling..." -ForegroundColor Yellow
|
Write-Host "Already inside the dotfiles repository. Skipping clone step and pulling..." -ForegroundColor Yellow
|
||||||
git pull
|
Write-Host "$(git pull)"
|
||||||
return $cwd
|
return $cwd
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ function ReadyDotfilesRepo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Pulling latest changes from dotfiles repository..." -ForegroundColor Cyan
|
Write-Host "Pulling latest changes from dotfiles repository..." -ForegroundColor Cyan
|
||||||
git -C $destination pull
|
Write-Host "$(git -C $destination pull)"
|
||||||
return $destination
|
return $destination
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,9 +78,16 @@ function ProcessUrlFiles
|
|||||||
param (
|
param (
|
||||||
[string]$source,
|
[string]$source,
|
||||||
[Parameter(Mandatory=$false)][string]$destination,
|
[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
|
# Ensure the destination directory exists
|
||||||
if ($destination -and (-not (Test-Path $destination)))
|
if ($destination -and (-not (Test-Path $destination)))
|
||||||
{
|
{
|
||||||
@ -125,7 +132,7 @@ function ProcessUrlFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "Downloading $fileName from $url$conditional..." -ForegroundColor Cyan
|
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"
|
$tmpDestination = "$tmpApp\$fileName$extension"
|
||||||
|
|
||||||
# Copy only if destination is provided
|
# Copy only if destination is provided
|
||||||
@ -168,6 +175,11 @@ function UnzipAndInstall
|
|||||||
{ New-Item -ItemType Directory -Path $tmpApp | Out-Null
|
{ 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
|
# Find all .url files in the source directory
|
||||||
$urlFiles = Get-ChildItem -Path $source -Filter '*.url'
|
$urlFiles = Get-ChildItem -Path $source -Filter '*.url'
|
||||||
|
|
||||||
@ -178,6 +190,6 @@ function UnzipAndInstall
|
|||||||
Expand-Archive "$tmpApp\$fileName.zip" -DestinationPath "$tmpApp\$fileName" | Out-Null
|
Expand-Archive "$tmpApp\$fileName.zip" -DestinationPath "$tmpApp\$fileName" | Out-Null
|
||||||
|
|
||||||
Write-Host "Installing fonts from $tmpApp\$fileName\ for current user..." -ForegroundColor Cyan
|
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
|
function InstallWinget
|
||||||
{
|
{
|
||||||
# Reference: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox
|
|
||||||
$progressPreference = 'silentlyContinue'
|
$progressPreference = 'silentlyContinue'
|
||||||
Write-Host "Installing WinGet PowerShell module from PSGallery..."
|
$download = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
|
||||||
Install-PackageProvider -Name NuGet -Force | Out-Null
|
$setup = "$env:TMP\winget_setup.msixbundle"
|
||||||
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
|
|
||||||
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
|
if (-not (Test-Path $setup))
|
||||||
Repair-WinGetPackageManager
|
{
|
||||||
|
$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
|
function WingetInstall
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
function InstallWSL
|
function InstallWSL
|
||||||
{
|
{
|
||||||
# Reference: https://learn.microsoft.com/en-us/windows/wsl/install-manual
|
Write-Host "Enabling and downloading required Windows Features..."
|
||||||
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
|
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All -NoRestart | Out-Null
|
||||||
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
|
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -All -NoRestart | Out-Null
|
||||||
wsl.exe --update
|
Write-Host "Installing WSL2..."
|
||||||
|
wsl.exe --install --no-distribution
|
||||||
wsl.exe --set-default-version 2
|
wsl.exe --set-default-version 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,8 +35,8 @@ function WSLInstall
|
|||||||
wsl.exe --install -d Ubuntu
|
wsl.exe --install -d Ubuntu
|
||||||
|
|
||||||
# Add newly created user to sudoers group
|
# Add newly created user to sudoers group
|
||||||
$user = wsl.exe cut "-d:" "-f1" /etc/passwd
|
$user = wsl.exe cut "-d:" "-f1" /etc/passwd | Select-Object -Last 1
|
||||||
wsl.exe -u root echo "echo ""$user ALL=(ALL) NOPASSWD:ALL"" >> /etc/sudoers.d/$user"
|
wsl.exe -u root echo "$user ALL=(ALL) NOPASSWD:ALL" ">>" "/etc/sudoers.d/$user"
|
||||||
|
|
||||||
# Update packages and install from list
|
# Update packages and install from list
|
||||||
wsl.exe sudo apt update "&&" sudo apt upgrade "-y"
|
wsl.exe sudo apt update "&&" sudo apt upgrade "-y"
|
||||||
@ -48,12 +49,12 @@ function InstallWSLNeovim
|
|||||||
[string]$source
|
[string]$source
|
||||||
)
|
)
|
||||||
|
|
||||||
Import-Module ./windows.psm1
|
Import-Module ./util/windows.psm1
|
||||||
|
|
||||||
ProcessUrlFiles -sourceDir $source
|
|
||||||
|
|
||||||
Push-Location
|
Push-Location
|
||||||
|
ProcessUrlFiles -source $source
|
||||||
Set-Location "$env:TMP\nvim-config"
|
Set-Location "$env:TMP\nvim-config"
|
||||||
|
|
||||||
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
|
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
|
||||||
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
|
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
Loading…
Reference in New Issue
Block a user