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
extra/gnu-free-fonts 20120503-8
A free family of scalable outline fonts
extra/noto-fonts 20201226-2
Google Noto TTF fonts
extra/noto-fonts-extra 20201226-2
Google Noto TTF fonts - additional variants
extra/sdl2_ttf 2.0.15-2
A library that allows you to use TrueType fonts in your SDL applications (Version 2)
extra/ttf-bitstream-vera 1.10-14
Bitstream Vera fonts.
extra/ttf-caladea 20200113-3
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 pacman -S.
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
pacman -Sstogrepwhere 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 expressions/^.\+\///, 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
xargswith the-aflag which passes the list of packages topacman. The reason we can't just pipe the output of the second grep toxargsis becausepacmanrequires 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.
Comments
Currently the comment submission form is not active. You can add a comment via pull request.There are no comments on this article yet.