summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/defaults/commands.py22
-rw-r--r--ranger/help/console.py3
2 files changed, 25 insertions, 0 deletions
diff --git a/ranger/defaults/commands.py b/ranger/defaults/commands.py
index e33cc2f1..d4c00f60 100644
--- a/ranger/defaults/commands.py
+++ b/ranger/defaults/commands.py
@@ -277,6 +277,28 @@ class delete(Command):
 		# no need for a confirmation, just delete
 		self.fm.delete()
 
+
+class mark(Command):
+	"""
+	:mark <regexp>
+
+	Mark all files matching a regular expression.
+	"""
+
+	def execute(self):
+		import re
+		cwd = self.fm.env.cwd
+		line = parse(self.line)
+		input = line.rest(1)
+		searchflags = re.UNICODE
+		if input.lower() == input: # "smartcase"
+			searchflags |= re.IGNORECASE 
+		pattern = re.compile(input, searchflags)
+		for fileobj in cwd.files:
+			if pattern.search(fileobj.basename):
+				cwd.mark_item(fileobj, val=True)
+
+
 class mkdir(Command):
 	"""
 	:mkdir <dirname>
diff --git a/ranger/help/console.py b/ranger/help/console.py
index c62d0244..d88cc267 100644
--- a/ranger/help/console.py
+++ b/ranger/help/console.py
@@ -94,6 +94,9 @@ it conflicts with ":cd".
       Looks for a string in all marked files or directory.
       (equivalent to "!grep [some options] -e <string> -r %s | less")
 
+:mark <regexp>
+      Mark all files matching a regular expression.
+
 :mkdir <dirname>
       Creates a directory with the name <dirname>