Luke Smith's two latest videos were on piping in the bash shell. I found these very interesting to watch, although they didn't teach me that much. One thing I did find quite fascinating was the ability to generate a PDF of a man page using groff. This was something I was previously unaware of, and I personally quite like the look of the PDF versions of man pages.
His idea was to use dmenu to select a man page, generate a PDF and send that straight to a PDF reader like zathura to view the man page in that nice format without actually saving the PDF at any point. This is actually the most useful use case for this feature, I personally now have that bound to $mod+m.
However, I wouldn't be writing a quick blog post right now if I hadn't unleashed my own creativity on this. Earlier today, I got bored and I decided to play around with this cool feature. Within a few minutes, I had written a shell script that gets a list of all of the manuals I have from man -k . and generates the PDF manual using man with the -Tpdf flag.
This is the script:
All this relies on is that there is a directory called manuals in your working directory. For my laptop, the script ended up creating over 7000 PDF's taking up a total of 121MB of space.
In other news, this marks the single terminal command I have ever executed that didn't involve an infinite loop or a video or stream that took the longest time to finish. I don't even know exactly how long it took because I ended up just leaving it running and watching an episode of Rick and Morty because I got bored again.
I am most likely going to end up deleting the entire directory without doing anything with this, because any time I need a PDF manual I'll just use the $mod+m shortcut like any normal human being would. The concepts used in this little script are nice, the actual script is useless AF.
His idea was to use dmenu to select a man page, generate a PDF and send that straight to a PDF reader like zathura to view the man page in that nice format without actually saving the PDF at any point. This is actually the most useful use case for this feature, I personally now have that bound to $mod+m.
However, I wouldn't be writing a quick blog post right now if I hadn't unleashed my own creativity on this. Earlier today, I got bored and I decided to play around with this cool feature. Within a few minutes, I had written a shell script that gets a list of all of the manuals I have from man -k . and generates the PDF manual using man with the -Tpdf flag.
This is the script:
#!/usr/bin/env bash
IFS='
'
for pkg in $(man -k .)
do
pkg_name=$(echo $pkg | awk '{print $1}')
man -Tpdf $pkg_name > ./manuals/$pkg_name.pdf
done
All this relies on is that there is a directory called manuals in your working directory. For my laptop, the script ended up creating over 7000 PDF's taking up a total of 121MB of space.
In other news, this marks the single terminal command I have ever executed that didn't involve an infinite loop or a video or stream that took the longest time to finish. I don't even know exactly how long it took because I ended up just leaving it running and watching an episode of Rick and Morty because I got bored again.
I am most likely going to end up deleting the entire directory without doing anything with this, because any time I need a PDF manual I'll just use the $mod+m shortcut like any normal human being would. The concepts used in this little script are nice, the actual script is useless AF.
Comments
Post a Comment