diff options
author | hut <hut@lavabit.com> | 2010-04-27 00:43:31 +0200 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-04-27 00:43:31 +0200 |
commit | e209b66101e475a0aa85d5eed3dbe0e8307ffba0 (patch) | |
tree | 6a587bf757114d48219b4c441d7ac298b44c2f73 /ranger | |
parent | f54d0ec7c8e9f3733e09ff392f1462622e5698ef (diff) | |
download | ranger-e209b66101e475a0aa85d5eed3dbe0e8307ffba0.tar.gz |
Added :mark command
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/defaults/commands.py | 22 | ||||
-rw-r--r-- | ranger/help/console.py | 3 |
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> |