summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xranger/ext/rifle.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py
index e5cf17b4..dff87b5a 100755
--- a/ranger/ext/rifle.py
+++ b/ranger/ext/rifle.py
@@ -373,9 +373,19 @@ def main():
         conf_path = os.environ['XDG_CONFIG_HOME'] + '/ranger/rifle.conf'
     else:
         conf_path = os.path.expanduser('~/.config/ranger/rifle.conf')
+    default_conf_path = conf_path
     if not os.path.isfile(conf_path):
         conf_path = os.path.normpath(os.path.join(os.path.dirname(__file__),
             '../config/rifle.conf'))
+    if not os.path.isfile(conf_path):
+        try:
+            # if ranger is installed, get the configuration from ranger
+            import ranger
+        except ImportError:
+            pass
+        else:
+            conf_path = os.path.join(ranger.__path__[0], "config", "rifle.conf")
+
 
     # Evaluate arguments
     from optparse import OptionParser
@@ -396,6 +406,11 @@ def main():
         parser.print_help()
         raise SystemExit(1)
 
+    if not os.path.isfile(conf_path):
+        sys.stderr.write("Could not find a configuration file.\n"
+                "Please create one at %s.\n" % default_conf_path)
+        raise SystemExit(1)
+
     if options.p.isdigit():
         number = int(options.p)
         label = None