summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/config/commands.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 68714009..fc034cf0 100644
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -685,6 +685,18 @@ class rename(Command):
     def tab(self):
         return self._tab_directory_content()
 
+class renameConsole(Command):
+    """:renameCommand
+
+    Creates an open_console for the rename command, automatically placing the cursor before the file extension.
+    """
+
+    def execute(self):
+        if "." in self.fm.thisfile.basename:
+            offset = 6 + len(self.fm.thisfile.basename) - self.fm.thisfile.basename[::-1].index('.')
+            self.fm.open_console('rename ' + self.fm.thisfile.basename, position=offset)
+        else:
+            self.fm.open_console('rename ' + self.fm.thisfile.basename)
 
 class chmod(Command):
     """:chmod <octal number>