Skip to content

Instantly share code, notes, and snippets.

@jp-hoehmann
Last active July 26, 2020 23:44
Show Gist options
  • Save jp-hoehmann/fc15eb998c305f8fc8123bf471971e79 to your computer and use it in GitHub Desktop.
Save jp-hoehmann/fc15eb998c305f8fc8123bf471971e79 to your computer and use it in GitHub Desktop.
Fetch all manpages available in packages into the current directory
#!/usr/bin/env -S bash -euo pipefail
#
# Fetch all available manpages.
#
n=$(apt-cache pkgnames | wc -l)
i=0
for e in $(apt-cache pkgnames)
do
echo "Fetching $e ($((++i)) of $n)" >&2
apt-get --print-uris download $e \
| perl -ne 'print "$1\n" if /^'"'"'(.*?)'"'"'/' \
| xargs -r curl -sL -o- \
| dpkg-deb --fsys-tarfile /dev/stdin \
|| :
done \
| tar xv --ignore-zeros ./usr/share/man \
| perl -pe 's/^/+ /'
@jp-hoehmann
Copy link
Author

jp-hoehmann commented Mar 25, 2019

This will run for a couple hours, since it has to download all the packages, but the actual manpages it downloads only consume a few hundred megabytes. Afterward all you need to do is add the new directory to your MANPATH and you will never see No manual entry for foo ever again.

@jp-hoehmann
Copy link
Author

jp-hoehmann commented Jul 26, 2020

Quickstart:

$ mkdir /usr/local/share/extra-manpages
$ wget https://gist.githubusercontent.com/NuvandaPV/fc15eb998c305f8fc8123bf471971e79/raw/be4a4a93665875b3699ba1eb24a5f778950cb8de/fetch-manpages.sh
$ chmod +x fetch-manpages.sh
$ ./fetch-manpages.sh

As /usr/local/share/extra-manpages/usr/share/man is usually configured to automatically be included in the manpath, this should be all that is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment