How to set file association in Ranger

File association is used to determine what program to use to open a file. All the file associations for Ranger can be found in ~/.config/ranger/rifle.conf file. This file is well documented and should answer most of your queries. Note that the file is read from top to bottom and the rule that matches first is chosen and applied.

In Ranger, you can choose a program to open a file based on its extension. For example, to open a JPEG file with Feh image viewer, add this line at the top of rifle.conf:

ext jpg = feh "$@"

After the specific file associations, I like to have a rule to catch all the rest of the files and open them using xdg-open:

has xdg-open, flag f = xdg-open "$1"

For more info on configuring Ranger, refer to the excellent documentation by Arch here.

Tried with: Ranger 1.6.1 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.