0

I'm not a fan of the default exploration for archives in Ranger, which resumes to showing the output of atool when opening the file.

I found out this avfs config, which allows you to explore an archive in ranger with the :avfs command. However, I want to be able to explore the archive just like a normal folder, and enter it by pressing l or .

Is there a way to configure Ranger to execute the :avfs command when opening these archives (i.e. when pressing l or on them)?


Related: How do I get a better preview for archives in ranger?

1 Answers1

0

If you want to execute a ranger command upon opening a file, there's a bit of a hack that you can use. That is remapping the l and keys to execute it with a bit of python. You should do this in .config/ranger/rc.conf.

Here's an example that will execute :avfs for the filetypes .tar.gz, .zip, and .7z:

map l eval fm.execute_console('avfs') if fm.thisfile.extension in ['zip', 'tar', 'gz', '7z'] else fm.move(right=1)

map <RIGHT> eval fm.execute_console('avfs') if fm.thisfile.extension in ['zip', 'tar', 'gz', '7z'] else fm.move(right=1)

If you want to configure a shell command to explore the file in a program outside of ranger, you're looking at .config/ranger/rifle.conf. If you don't know how to configure it, I recommend reading the default rifle.conf. There's a big comment at the beginning explaining how to use it, and it's full good examples.