dotfiles

My personal dotfiles 💠️

commands.py (487B)

      1 from ranger.api.commands import Command
      2 from os.path import join, expanduser
      3 
      4 class rename(Command):
      5     """:rename <destination>
      6 
      7     Renames a file
      8     """
      9 
     10     def execute(self):
     11         source = self.fm.thisfile
     12         destination = join(self.fm.thisdir.path, expanduser(self.rest(1)))
     13         destination = destination.strip()
     14 
     15         if destination:
     16             self.fm.run("mv '%s' '%s'" % (source, destination))
     17         else:
     18             self.fm.notify("Cancelled", bad=True)
     19