Last active
May 21, 2026 22:46
-
-
Save tororutsu/5e4419f87d92d599b538c353068cd7e0 to your computer and use it in GitHub Desktop.
View Fonts Nicely with Elvish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env elvish | |
| use str | |
| var fonts = [&] | |
| # 1. Grab fonts from the system and split them into lines | |
| fc-list --format="%{family}|%{style}\n" | from-lines | each {|line| | |
| var parts = [(str:split '|' $line)] | |
| if (== (count $parts) 2) { | |
| # Isolate the primary family name and style (ignoring comma aliases) | |
| var family = (str:trim-space [(str:split ',' $parts[0])][0]) | |
| var style = (str:trim-space [(str:split ',' $parts[1])][0]) | |
| # 2. Build a nested dictionary grouping styles by family | |
| if (not (has-key $fonts $family)) { | |
| set fonts[$family] = [&] | |
| } | |
| set fonts[$family][$style] = $true | |
| } | |
| } | |
| # 3. Print the dictionary with formatting | |
| for family [(keys $fonts | order)] { | |
| echo (styled $family green bold) | |
| var styles = [(keys $fonts[$family] | order)] | |
| echo " ↳ "(styled (str:join ", " $styles) italic) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment