1. 15
  1. 5

    If you use Neovim, you can use the builtin man page plugin.

    For example: https://i.imgur.com/eLNmYkh.png

    Checkout https://github.com/neovim/neovim/blob/611351677dba450fc1a312061572c44c7e3d6482/runtime/doc/filetype.txt#L509 for docs and how to use it as the default man pager.

    1. 3

      This is a fantastic tip. Thanks for sharing.

    2. 5

      This is definitely a quality-of-life thing that you only notice when it’s gone. I typically use it as a function, but since it’s the shell, there’s ten thousand ways to do it. Here’s (my) fish shell version for copy-paste:

      function man -d "Pretty manpages"
          env \
              LESS_TERMCAP_mb=(printf "\e[1;31m") \
              LESS_TERMCAP_md=(printf "\e[1;31m") \
              LESS_TERMCAP_me=(printf "\e[0m") \
              LESS_TERMCAP_se=(printf "\e[0m") \
              LESS_TERMCAP_so=(printf "\e[1;44;33m") \
              LESS_TERMCAP_ue=(printf "\e[0m") \
              LESS_TERMCAP_us=(printf "\e[1;32m") \
                  man $argv
      1. 2

        That’s nice. Going to use that for sure.

        FYI fish has a set_color builtin that might make that a bit more readable.

      2. 3

        I ran into exactly the same bug when I tried to move the not-so-nice environment variables out of my profile and into the lesskey file. Ultimately I never got around to finding out why it wouldn’t work - but together with someone else, came up with a small C wrapper around less(1) which lets the user set colours in a more sane manner.

        With this, you only have to do:

        export MANPAGER_COLORS='md=31,me=,us=4;35,ue='
        export MANPAGER=manpager

        See here for a more detailed description along with the source code.

        1. 2

          This is great, I like that it avoids polluting the shell environment.

          The issue should be fixed in the most recent less version (released just 10 days ago) but most systems won’t have this up-to-date version so there is still a need for a solution like yours to set the variables elsewhere.

        2. 3

          If you like adding colors to commands that lack it, I’ve found the Generic Colouriser really helpful, and very easy to use. E.g., here’s adding colors to Fossil with it.

          1. 2

            If you’re on macOS and already have Dash.app installed, check out open dash://manpages:$1 (e.g. open dash://manpages:ls).

            1. 3

              And if you want a nice-ish PDF:

              man -t ls | open -fa Preview

              1. 3

                I put together a script for that. It’s a little overengineered to catch missing dependencies, but it’s kinda nice because it puts the PDF output in $TMPDIR as a cache for subsequent retrievals of the same manpage.


            2. 2

              setting PAGER=most does this automatically too.

              1. 1

                I use vim as my PAGER in order to get a consistent highlighting and colour scheme.

                Easiest way to do this is via https://github.com/rkitover/vimpager - but you can also use the “less.sh” wrapper that’s included with vim.

                export PAGER=vimpager or export PAGER=/usr/local/share/vim/macros/less.sh

                (Path will obviously vary based on your OS, etc.)

                On MacOS, “brew install vimpager” will be quickest.