
When the files are lined up like this
:mark_similars
Then

Only files with similar names can be marked!
It is convenient to map it appropriately in rc.conf.
commands.py
from ranger.api.commands import *
class mark_similars(Command):
  """
  :mark_similars [<NAME>]
  Mark all similar files by the name.
  """
  do_mark = True
  def execute(self):
    from re import compile, sub, I, UNICODE
    arg = self.rest(1)
    if not arg:
      arg = self.fm.thisfile.basename
    pattern = compile('^' + sub(r'[^A-Gaa-Nichi-龠 a-zA-Z]+', '.+', arg) + '$', I | UNICODE)
    cwd = self.fm.thisdir
    for file in cwd.files:
      if pattern.search(file.basename):
        #cwd.mark_item(file, val=self.do_mark)
        cwd.toggle_mark(file)
    self.fm.ui.status.need_redraw = True
    self.fm.ui.need_redraw = True
Recommended Posts