mirror of
https://github.com/Baipyrus/dotfiles.git
synced 2024-12-26 11:21:46 +00:00
unzip all nerd-font zip archives in parent directory
This commit is contained in:
parent
d79c3bf43f
commit
05de50080a
@ -63,7 +63,8 @@ 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" -progress $false
|
ProcessUrlFiles -source "$dotfilesRepo\nerd-fonts" -fileExt ".zip" -progress $false
|
||||||
UnzipAndInstall -source "$dotfilesRepo\nerd-fonts" -destination "$env:LOCALAPPDATA\Microsoft\Windows\Fonts\"
|
Get-ChildItem -Path "$env:TMP\nerd-fonts-config" -Filter "*.zip" | `
|
||||||
|
ForEach-Object { InstallNerdFont -source $_.FullName }
|
||||||
|
|
||||||
# Final message
|
# Final message
|
||||||
Write-Host "Windows setup complete!" -ForegroundColor Green
|
Write-Host "Windows setup complete!" -ForegroundColor Green
|
||||||
|
@ -161,35 +161,34 @@ function ProcessUrlFiles
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to expand zip archives and copy to destination paths
|
# Function to unzip and install nerd fonts
|
||||||
function UnzipAndInstall
|
function InstallNerdFont
|
||||||
{
|
{
|
||||||
param (
|
param (
|
||||||
[string]$source,
|
[string]$source
|
||||||
[string]$destination
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create temporary directory for unzip
|
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($source)
|
||||||
$appname = $source.Split('\')[-1]
|
$parent = $source -split '\\' | Select-Object -SkipLast 1 | Join-String -Separator '\'
|
||||||
$tmpApp = "$env:TMP\$appname-config"
|
$destination = "$parent\$fileName"
|
||||||
if (-not (Test-Path $tmpApp))
|
|
||||||
{ New-Item -ItemType Directory -Path $tmpApp | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
|
# Create destination directory
|
||||||
if (-not (Test-Path $destination))
|
if (-not (Test-Path $destination))
|
||||||
{ New-Item -ItemType Directory -Path $destination | Out-Null
|
{ New-Item -ItemType Directory -Path $destination | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find all .url files in the source directory
|
# Extract contents of zip archive
|
||||||
$urlFiles = Get-ChildItem -Path $source -Filter '*.url'
|
Write-Host "Extracting archive $source to $destination..." -ForegroundColor Cyan
|
||||||
|
Expand-Archive $source -DestinationPath $destination | Out-Null
|
||||||
|
|
||||||
foreach ($file in $urlFiles)
|
# Install extracted fonts
|
||||||
|
$fontFiles = Get-ChildItem -Path $destination -Include "*.ttf", "*.otf"
|
||||||
|
|
||||||
|
foreach ($font in $fontFiles)
|
||||||
{
|
{
|
||||||
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
|
# TODO:
|
||||||
Write-Host "Extracting archive $tmpApp\$fileName.zip to $tmpApp\$fileName\..." -ForegroundColor Cyan
|
}
|
||||||
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 $destination -Force -ErrorAction SilentlyContinue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user