Create a ~bin/fileopen.sh file with this content:
#!/bin/bash
log=$HOME/.xlog
path=${1#file://}
if [ -d $path ]
then
/usr/bin/xterm -e "/usr/bin/ranger $path" &>> $log
else
/usr/bin/xterm -e "/usr/bin/ranger --selectfile=$path" &>> $log
fi
Of course you make your script executable:
chmod 755 ~bin/fileopen.sh
In Firefox go to Edit > Preferences > Applications
Set the action for the type "file" and whatever other entries to use your fileopen.sh 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 fileopen.sh 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