about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-01-22 20:29:36 +0100
committertoonn <toonn@toonn.io>2021-01-22 20:29:36 +0100
commit6e78bbe39a5a5edecf6021788a63799333fa7e43 (patch)
treed1a6ecdac2e7713f633db706e90655bb19b6cc23 /ranger
parent73bcd80c1c3e721391c75015cb4ec03532357ad9 (diff)
parent785102b5b0da2828ade2e7752d151144ab7524f5 (diff)
downloadranger-6e78bbe39a5a5edecf6021788a63799333fa7e43.tar.gz
Merge branch 'chu4ng-console-pos-flag'
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/config/commands.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 9031e7a2..ea2ab982 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -828,21 +828,32 @@ class mark_tag(Command):
 
 
 class console(Command):
-    """:console <command>
+    """:console [-p N | -s sep] <command>
 
+    Flags:
+     -p N   Set position at N index
+     -s sep Set position at separator(any char[s] sequence), example '#'
     Open the console with the given command.
     """
 
     def execute(self):
         position = None
+        command = ""
         if self.arg(1)[0:2] == '-p':
+            command = self.rest(2)
             try:
                 position = int(self.arg(1)[2:])
             except ValueError:
                 pass
+        elif self.arg(1)[0:2] == '-s':
+            command = self.rest(3)
+            separate = self.arg(2)
+            position = command.find(separate)
+            if position != -1:
+                command = command.replace(separate, '', 1)
             else:
-                self.shift()
-        self.fm.open_console(self.rest(1), position=position)
+                position = None
+        self.fm.open_console(command, position=position)
 
 
 class load_copy_buffer(Command):