Previewer for archives
bennyyip opened this issue · comments
Currently hunter preview archives with 7z, but it does not support many widely used archive formats, like tgz, tar.gz, tar.xz. I suppose we can preview archives like ranger.
For example, ranger use atool
or bsdtar
(while atool
is not available) to preview tgz(https://github.com/ranger/ranger/blob/b1abf1327f38853f0101c585c2b1e868df400f9d/ranger/data/scope.sh#L52).
Done!
Back when hunter used scope for previews I actually disabled previews for tar archives, because they're really slow to generate and worse, atool and I noticed even bsdtar, spawn child processes that don't get killed when their main process gets the SIGTERM/SIGKILL signal, so in a directory with many archives it was easily possible to spawn dozens of processes, all extracting the archives and thrashing the system to a halt.
I improved the subprocess tracker/killer by making use of process groups. That seems to nicely fix the problem with the left over processes.
I also made bsdtar the default previewer, since it's likely the most widely installed since it's part of libarchive, with 7z/atool as fallbacks. Since bsdtar's default column order is pretty much the opposite of what you would want in hunter (file names are on the right side and can easily get cut off) I hacked up a simple parser/rewriter along the way to make it fit in better.
At some point I want to make it possible to actually browse archives seamlessly, like they're just directories, including full r/w access. But that's for another time.
Anyway, let me know if there's anything broken. Oh, and if you didn't manually edit any previewers you can just delete ~/.config/hunter/previewers
and it will update everything to the latest version.
BTW, you can update your config with with by running hunter -u
now. If you have made any modifications however, it would overwrite them. But you can also just delete the previewer script in ~.config/hunter/previewers/definitions/archive
. hunter will then re-add the missing file automatically (this is also new).