Arch Linux takes its bottom up approach very seriously and the system you start with has basically nothing but the bare essentials installed. I got a bit tired of seeing glitchy text on the web because my system didn't have have them, so since I have a pretty powerful computer with a ton of storage I thought I would install all the available fonts in the repos. So I went to the shell and did
$ pacman -Ss ttf font
and got output that looked something like
A free family of scalable outline fonts
Google Noto TTF fonts
Google Noto TTF fonts - additional variants
A library that allows you to use TrueType fonts in your SDL applications (Version 2)
Bitstream Vera fonts.
A serif font family metric-compatible with Cambria font family
It was a pretty long list of packages, all with pretty long names, and I really couldn't be bothered typing all of those out.
So I started digging to figure out how I could use the output from
pacman -Ss to
I came up with the following (probably less than optimal) solution:
xargs -a <(pacman -Ss ttf font | grep "^[a-zA-Z0-9]" | sed 's/^.\+\///; s/\ .*$//' | grep -v "ttf-nerd-fonts-symbols-mono") sudo pacman -S
It probably took me longer to figure out how to do this and to then write this blog post about it, but anyway, let's disect it:
- Inside the parentheses we pipe the output from
grepwhere we only want to get the lines that start with a letter and number. The regular expression
^[a-zA-Z0-9]will achieve this. The indented lines describe the package and are useless; they are filtered out.
- We pipe those lines to
sed, where we remove everything before the forward slash with the expression
s/^.\+\///, where we look for the start of the line (
^), then any kind of characters (
.) a number of times (
\+), then a slash
\/and we replace with nothing. We also remove everything after the space (
\) until the end of the line (
- (Optional) I piped this again to grep because this package conflicted with another package. With
-v, I let everything pass except the matches
- This is directed to
-aflag which passes the list of packages to
pacman. The reason we can't just pipe the output of the second grep to
pacmanrequires yes/no confirmation, which is not possible in that mode. A helpful stack exchange thread on this can be found here.
Hopefully this could be helpful if you want to do something similar.