Skip to content

Instantly share code, notes, and snippets.

@avonmoll
Created February 28, 2020 15:03
Show Gist options
  • Save avonmoll/eeb826e14e3f5034893ce96a3a003c08 to your computer and use it in GitHub Desktop.
Save avonmoll/eeb826e14e3f5034893ce96a3a003c08 to your computer and use it in GitHub Desktop.
ranger with MuPDF for PDF preview

ranger is a great terminal-based file manager. For a long time, I used pdftoppm for image-based PDF previews which is the recommended approach. However, I found it was difficult to install pdftoppm everywhere (particularly, macos) and finally turned to MuPDF, which was much easier to get.

In order to use MuPDF, I changed the PDF case within the handle_image() function inside scope.sh to the following:

application/pdf)
    mutool draw -F png -o "${IMAGE_CACHE_PATH}" "${FILE_PATH}" 1 \
        && exit 6 || exit 1;;

Incidentally, it looks like ranger has started to use mutool draw for the PDF to txt conversion (see here).

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