Configure `fzf` in Ranger
We used AI while writing this content.
fzf is a fast, open‑source command‑line “fuzzy finder” tool that lets you search and filter lists interactively. You can integrate it into ranger to improve its search capacities.
-
Install fzf
sudo apt install fzf # Debian/Ubuntu sudo pacman -S fzf # Arch brew install fzf # macOS which fzf -
Add the custom commands to ranger
Edit (or create)~/.config/ranger/commands.pyand add:from ranger.api.commands import Command import subprocess class fzf_select(Command): def execute(self): fzf = subprocess.Popen( 'find -L . -type f 2>/dev/null | fzf +m', shell=True, stdout=subprocess.PIPE ) stdout, _ = fzf.communicate() if fzf.returncode == 0: self.fm.select_file(stdout.decode('utf-8').strip()) class fzf_select_directories(Command): def execute(self): fzf = subprocess.Popen( 'find -L . -type d 2>/dev/null | fzf +m', shell=True, stdout=subprocess.PIPE ) stdout, _ = fzf.communicate() if fzf.returncode == 0: self.fm.select_file(stdout.decode('utf-8').strip()) -
Restart ranger
After saving, restart ranger. Now you can run::fzf_select→ fuzzy search files:fzf_select_directories→ fuzzy search directories
Member discussion