about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorrukai <rubickent@gmail.com>2014-08-17 20:10:36 +1000
committerrukai <rubickent@gmail.com>2014-08-17 20:10:36 +1000
commit5210a0d5b022725ff5e0165ec5bd7de5f84ecc8d (patch)
tree8c66a9588f2e523b6e09301a57f6b0d596df733c
parent8202d055f8e413e61950342d1a214f2c43254e58 (diff)
downloadranger-5210a0d5b022725ff5e0165ec5bd7de5f84ecc8d.tar.gz
Added renameConsole a command which automatically creates a console for the rename command and places the cursor before the file extension.
-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>