@@ -821,16 +821,24 @@ internal.man_pages = function(opts)
821821 opts .sections = vim .F .if_nil (opts .sections , { " 1" })
822822 assert (utils .islist (opts .sections ), " sections should be a list" )
823823 opts .man_cmd = utils .get_lazy_default (opts .man_cmd , function ()
824+ local cache = Path :new (vim .fn .stdpath " cache" , " telescope-man-pages" )
825+ if cache :exists () and cache :_stat ().size > 0 and os.time () - cache :_stat ().mtime .sec < 24 * 60 * 60 then
826+ return { " cat" , cache .filename }
827+ end
828+
824829 local uname = vim .loop .os_uname ()
825830 local sysname = string.lower (uname .sysname )
831+ local cmd
826832 if sysname == " darwin" then
827833 local major_version = tonumber (vim .fn .matchlist (uname .release , [[ ^\(\d\+\)\..*]] )[2 ]) or 0
828- return major_version >= 22 and { " apropos" , " ." } or { " apropos" , " " }
834+ cmd = major_version >= 22 and " apropos ." or " apropos ' ' "
829835 elseif sysname == " freebsd" then
830- return { " apropos" , " . " }
836+ cmd = " apropos . "
831837 else
832- return { " apropos" , " " }
838+ cmd = " apropos '' "
833839 end
840+
841+ return { " sh" , " -c" , string.format (" %s | tee %s" , cmd , cache .filename ) }
834842 end )
835843 opts .entry_maker = opts .entry_maker or make_entry .gen_from_apropos (opts )
836844 opts .env = { PATH = vim .env .PATH , MANPATH = vim .env .MANPATH }
0 commit comments