Ranger is advanced file manager (like mc, Nautilus, Total Commander, …) but it uses key bindings and shortcuts like vim. It is in Debian’s repositories.
fzf (command-line fuzzy finder) is tool for searching files and directories. You can download it from github.com/junegunn/fzf
For integration create (or open) file ~/.config/ranger/commands.py and add function fzf_select. All file should looks like this:
from ranger.api.commands import Command
class fzf_select(Command):
"""
:fzf_select
Find a file using fzf.
With a prefix argument select only directories.
See: https://github.com/junegunn/fzf
"""
def execute(self):
import subprocess
import os.path
fzf = self.fm.execute_command("fzf +m", universal_newlines=True, stdout=subprocess.PIPE)
stdout, stderr = fzf.communicate()
if fzf.returncode == 0:
fzf_file = os.path.abspath(stdout.rstrip('\n'))
if os.path.isdir(fzf_file):
self.fm.cd(fzf_file)
else:
self.fm.select_file(fzf_file)
Then restart ranger and type :fzf_select and start using fzf in ranger.
Pingback: Change prompt in Ranger | posvic.eu
Unfortunately in my home directory and all directories above that, the fzf command does not stop running, even though a correct fzf_file could be retrieved. Do you have any ideas why this happens?
Does it happen only in Ranger or in pure fzf (when you run fzf command in terminal)?