Monday, 30 November 2015

Set ranger as the default file manager of Firefox

I have just created a short script for using ranger (>=version 1.4.2) as the default file manager to open files from Firefox. This is how you make it:

Create a ~bin/ file with this content:



if [ -d $path ]

     /usr/bin/xterm -e "/usr/bin/ranger $path" &>> $log

     /usr/bin/xterm -e "/usr/bin/ranger --selectfile=$path" &>> $log

Of course you make your script executable:

chmod 755 ~bin/

In Firefox go to Edit > Preferences > Applications
Set the action for the type "file" and whatever other entries to use your script for opening these types of files. E.g. I have set "file", "GZ file", "Plain text document", "raw CD image", "shell script" and "Zip archive" types to be handled by ranger. Additionnally when Firefox asks how to open such a file, set it up to use as well.

You are done. Download something and/or open your recent download list in Firefox and an xterm window should pop up with a ranger instance opening the file. If the file is a directory (e.g. when you click "Open Containing Folder" in Firefox) then it will not only choose the directory in the tree but will also enter it.

No comments:

Post a Comment