[raw] [dotfiles.tar.gz]
   1 import os.path;
   2 import subprocess;
   3 from ranger.api.commands import Command;
   4 
   5 class fzf(Command):
   6     def execute(self):
   7         stdout, stderr = self.fm.execute_command(
   8             'find . -print 2>&- | sed "s/^\.$//" | cut -b 3- | fzf',
   9             universal_newlines=True,
  10             stdout=subprocess.PIPE
  11         ).communicate();
  12 
  13         if not stdout:
  14             return;
  15 
  16         path = os.path.abspath(stdout.rstrip('\n'));
  17 
  18         if os.path.isdir(path):
  19             self.fm.cd(path);
  20         else:
  21             self.fm.select_file(path);