🚀 [Feature]: Install only the Nerd Font variants you need with faster reruns#77
🚀 [Feature]: Install only the Nerd Font variants you need with faster reruns#77Marius Storhaug (MariusStorhaug) wants to merge 23 commits into
Conversation
Closes #71. The progress bar adds per-byte rendering overhead that is especially expensive in non-interactive hosts. \Continue is saved and restored so the user's session is unaffected.
There was a problem hiding this comment.
Pull request overview
This PR currently implements a small Install-NerdFont download optimization by suppressing Invoke-WebRequest progress rendering, and adds a script for measuring install performance scenarios.
Changes:
- Suppresses PowerShell progress output during font archive downloads while restoring the previous preference afterward.
- Adds a performance measurement script for single-font, subset, already-installed, and optional full install scenarios.
- Ignores generated performance JSONL results.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/functions/public/Install-NerdFont.ps1 |
Wraps the download call with temporary progress suppression. |
scripts/Measure-InstallPerformance.ps1 |
Adds a benchmark helper for repeatable install timing scenarios. |
.gitignore |
Excludes generated performance result output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements001 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements001 |
Closes #74. Replaces `+=` array accumulation with a generic List and deduplicates overlapping wildcards via an OrdinalIgnoreCase HashSet, so each font is downloaded, extracted, and installed at most once per invocation. Install loop moves to `end` so pipeline input is fully resolved before any I/O. Also suppresses Write-Host / unused-parameter analyzer warnings in the perf measurement script.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements002 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements002 |
Builds a HashSet of installed family names once per invocation. When -Force is not set, each font is checked against the set and skipped end-to-end (no download, no extract, no Install-Font call) if at least one installed family matches its base name. Wildcard match handles the multi-family layout of Nerd Fonts archives (e.g. 'Hack Nerd Font', 'Hack Nerd Font Mono'). Also restructure perf script call sites to splat (fixes PSUseConsistentIndentation).
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
Previous HashSet[string] constructor crashed with ArgumentNullException on a fresh runner where Get-Font returns no items. Coerce to a real string[] (empty when no fonts) before passing to the ctor.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements003 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements003 |
Replace Expand-Archive (which scans every entry through PowerShell and materializes file objects) with the direct .NET ZipFile.ExtractToDirectory call. Same behavior, much lower per-archive overhead.
Super-linter summary
Super-linter detected linting errors For more information, see the GitHub Actions workflow run Powered by Super-linter POWERSHELL |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.0.33-perfinstallimprovements004 |
|
✅ New prerelease: GitHub - NerdFonts v1.0.33-perfinstallimprovements004 |
| if (-not (Test-Path -LiteralPath $t.Q.CacheTagDir)) { | ||
| $null = New-Item -ItemType Directory -Path $t.Q.CacheTagDir -Force | ||
| } | ||
| [System.IO.File]::WriteAllBytes($t.Q.CachedFile, $bytes) | ||
| $readyToInstall.Add($t.Q) |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
| $keepNames = [string[]]@($keep.FullName) | ||
| $keepSet = [System.Collections.Generic.HashSet[string]]::new( | ||
| $keepNames, | ||
| [System.StringComparer]::OrdinalIgnoreCase | ||
| ) | ||
| $removed = 0 | ||
| foreach ($f in $allFiles) { | ||
| if (-not $keepSet.Contains($f.FullName)) { | ||
| Remove-Item -LiteralPath $f.FullName -Force -ErrorAction SilentlyContinue | ||
| $removed++ | ||
| } | ||
| } | ||
| Write-Verbose "[$fontName] - Variant '$Variant' kept $($keep.Count) files, removed $removed" |
| When you run `Install-NerdFont` again without `-Force`, fonts that are already installed in the requested scope are skipped. Downloaded archives are also cached per Nerd Fonts release so retries and repeated installs do not need to fetch the same ZIP again. | ||
|
|
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
| if (-not (Test-Path -LiteralPath $t.Q.CacheTagDir)) { | ||
| $null = New-Item -ItemType Directory -Path $t.Q.CacheTagDir -Force | ||
| } | ||
| [System.IO.File]::WriteAllBytes($t.Q.CachedFile, $bytes) |
|
Updated the default Install-NerdFont download parallelism to use the machine processor count instead of a fixed throttle. Focused validation passed locally for the touched install tests. |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
…rmance test results
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
|
|
||
| Add-Type -AssemblyName System.Net.Http -ErrorAction SilentlyContinue | ||
| $httpClient = [System.Net.Http.HttpClient]::new() | ||
| $httpClient.Timeout = [TimeSpan]::FromMinutes(5) |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
|
✅ New prerelease: PowerShell Gallery - NerdFonts 1.1.0-perfinstallimprovements002 |
|
✅ New prerelease: GitHub - NerdFonts v1.1.0-perfinstallimprovements002 |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
| {"Iteration":"1.0.33-pre006-variant-all","Scenario":"Single-Hack","DurationMs":1171,"DurationS":1.17,"Timestamp":"2026-05-17T14:05:52.0905786+02:00","Error":null,"Module":"1.0.33"} | ||
| {"Iteration":"1.0.33-pre006-variant-all","Scenario":"Subset-Hack+FiraCode+JetBrainsMono","DurationMs":6096,"DurationS":6.1,"Timestamp":"2026-05-17T14:06:02.0498948+02:00","Error":null,"Module":"1.0.33"} | ||
| {"Iteration":"1.0.33-pre006-variant-all","Scenario":"Subset-AlreadyInstalled","DurationMs":35,"DurationS":0.04,"Timestamp":"2026-05-17T14:06:02.1490854+02:00","Error":null,"Module":"1.0.33"} | ||
| {"timestampUtc":"2026-05-17T12:06:18.1677417Z","iteration":"1.0.33-pre006-variant-mono","scenario":"Subset-Mono","durationSeconds":1.62,"moduleVersion":"1.0.33-pre006"} |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
Install-NerdFont can now install only the Nerd Font variants you want, reuse cached archives between runs, and skip work for fonts that are already present in the requested scope. Multi-font installs also finish faster because archive downloads are batched and extraction uses the underlying .NET zip APIs directly.
New: Install only the variants you need
Use
-Variantto limit each archive to the families you actually want to register. This is useful for terminal-focused setups where only the monospace family is needed.Allremains the default, so existing scripts keep the current behavior unless they opt intoStandard,Mono, orPropo.Changed: Repeated installs reuse prior work
When a font is already installed in the requested scope and
-Forceis not used,Install-NerdFontnow skips the download, extraction, and install phases for that font. Downloaded archives are cached per Nerd Fonts release, so retries and overlapping reruns can reuse the same zip instead of fetching it again.Changed: Multi-font installs complete faster
Bulk installs now resolve the target font set once, avoid duplicate work from overlapping name patterns, download archives in bounded batches, and extract them with
System.IO.Compression.ZipFile. The end result is less waiting during-Alland other multi-font runs without changing the default install surface.Technical Details
Install-NerdFontnow deduplicates the resolved font list, skips already-installed fonts without-Force, caches archives under the user cache directory, downloads uncached archives throughSystem.Net.Http.HttpClient, extracts withSystem.IO.Compression.ZipFile, and filters extracted files by-Variantbefore callingInstall-Font.tests/NerdFonts.Tests.ps1adds coverage for-Variant Monoinstalls.scripts/Measure-InstallPerformance.ps1adds repeatable performance scenarios for single-font, subset, rerun, and optional-Allmeasurements.README.mdnow documents variant installs, skip-on-rerun behavior, and cache bypass with-Force.