summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--ranger/commands.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/ranger/commands.py b/ranger/commands.py
index dcc70dc7..95dfaf99 100644
--- a/ranger/commands.py
+++ b/ranger/commands.py
@@ -2,6 +2,7 @@ import os
 from ranger.shared import FileManagerAware
 from ranger.gui.widgets import console_mode as cmode
 from ranger.ext.command_parser import LazyParser as parse
+from ranger import log
 
 class Command(FileManagerAware):
 	"""Abstract command class"""
@@ -277,6 +278,22 @@ class filter(Command):
 		self.fm.set_filter(line.rest(1))
 	
 
+class grep(Command):
+	"""
+	:grep <string>
+
+	Looks for a string in all marked files or directories
+	"""
+	def execute(self):
+		from ranger.applications import run
+		line = parse(self.line)
+		if line.rest(1):
+			action = ['grep', '--color=always', '--line-number']
+			action.extend(['-e', line.rest(1), '-r'])
+			action.extend(map(lambda x: x.path, self.fm.env.get_selection()))
+			run(fm=self.fm, action=action, flags='p')
+
+
 # -------------------------------- rest
 
 by_name = {}
ail.com> 2014-07-17 00:28:39 +0100 committer James Booth <boothj5@gmail.com> 2014-07-17 00:28:39 +0100 Updated themes with roommention setting' href='/danisanti/profani-tty/commit/themes/original?id=8a113ad688ccbfa5dd3a5a807a0d2f9d986fa90c'>8a113ad6 ^
45a26b11 ^

9db02541 ^



373b3a2d ^





9db02541 ^




d39bcdc1 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49