From e209b66101e475a0aa85d5eed3dbe0e8307ffba0 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 27 Apr 2010 00:43:31 +0200 Subject: Added :mark command --- ranger/defaults/commands.py | 22 ++++++++++++++++++++++ ranger/help/console.py | 3 +++ 2 files changed, 25 insertions(+) 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 + + 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 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 -r %s | less") +:mark + Mark all files matching a regular expression. + :mkdir Creates a directory with the name -- cgit 1.4.1-2-gfad0