summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2012-04-26 20:08:01 +0200
committerhut <hut@lavabit.com>2012-05-06 18:37:08 +0200
commit52ba33919967827deb3042e70940239194b5b6e6 (patch)
treecdd004ebb615347d7cf7f9706296b08c60e693f6
parent38c23f61a3cabfd63acbca56fbeb9d2cc7493051 (diff)
downloadranger-52ba33919967827deb3042e70940239194b5b6e6.tar.gz
ext.rifle: Added "match", "file" and "directory" functions
Conflicts:

	ranger/ext/rifle.py
-rw-r--r--ranger/defaults/rifle.conf19
-rwxr-xr-xranger/ext/rifle.py6
2 files changed, 17 insertions, 8 deletions
diff --git a/ranger/defaults/rifle.conf b/ranger/defaults/rifle.conf
index 15a00dae..9ee15b25 100644
--- a/ranger/defaults/rifle.conf
+++ b/ranger/defaults/rifle.conf
@@ -13,14 +13,17 @@
 #
 # Prefixing a condition with "!" will negate its result.
 # These conditions are currently supported:
-#   ext <regexp>  | The regexp matches the extension of $1
-#   mime <regexp> | The regexp matches the mime type of $1
-#   name <regexp> | The regexp matches the basename of $1
-#   path <regexp> | The regexp matches the absolute path of $1
-#   has <program> | The program is installed (i.e. located in $PATH)
-#   number <n>    | change the number of this command to n
-#   terminal      | stdin, stderr and stdout are connected to a terminal
-#   X             | $DISPLAY is not empty (i.e. Xorg runs)
+#   match <regexp> | The regexp matches $1
+#   ext <regexp>   | The regexp matches the extension of $1
+#   mime <regexp>  | The regexp matches the mime type of $1
+#   name <regexp>  | The regexp matches the basename of $1
+#   path <regexp>  | The regexp matches the absolute path of $1
+#   has <program>  | The program is installed (i.e. located in $PATH)
+#   file           | $1 is a file
+#   directory      | $1 is a directory
+#   number <n>     | change the number of this command to n
+#   terminal       | stdin, stderr and stdout are connected to a terminal
+#   X              | $DISPLAY is not empty (i.e. Xorg runs)
 #
 # There are also pseudo-conditions which have a "side effect":
 #   flag <flags>  | Change how the program is run. See below.
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index aef6c54b..1080ecec 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -169,6 +169,12 @@ class Rifle(object):
 			return bool(re.search('^(' + argument + ')$', extension))
 		elif function == 'name':
 			return bool(re.search(argument, os.path.basename(files[0])))
+		elif function == 'match':
+			return bool(re.search(argument, files[0]))
+		elif function == 'file':
+			return os.path.isfile(files[0])
+		elif function == 'directory':
+			return os.path.isdir(files[0])
 		elif function == 'path':
 			return bool(re.search(argument, os.path.abspath(files[0])))
 		elif function == 'mime':